commandref.txt 145 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900
  1. # Never-do's in UNIX (The Unix programming environment - Mark Burgess page: 11)
  2. * Don't ever call a program or an important file 'core'. Many scripts go around
  3. deleting files called 'core' because, when a program crashes, UNIX dumps the
  4. entire kernel image to a file called 'core' and these files use up a lot of
  5. disk space. If you call a file 'core' it might get deleted!
  6. * Don't call test programs test. There is a UNIX command which is already
  7. called test and chances are that when you try to run your program you will
  8. start the UNIX command instead. This can cause a lot of confusion because the
  9. UNIX command doesn't seem to do very much at all!
  10. w.xx.y-zzz
  11. w - kernel version, xx - major revision, y - minor revision, zzz - patch number
  12. i386 - 32bit
  13. amd64 - 64bit
  14. Note:
  15. adding rw init=/bin/bash to boot parameters will open a full root session for
  16. anyone who happens to push the power button on your PC. If you think you might
  17. need this kind of access, I would advise you to create a secure BIOS or GRUB
  18. password to protect yourself.
  19. Note:
  20. always tar up a directory, not an individual files
  21. echo $LANG
  22. echo $MAIL # To output the location of your inbox
  23. echo $PATH
  24. echo $SHELL
  25. echo $TERM
  26. printenv # to display environment variables
  27. name=newton
  28. echo $name # $ symbol is used before a variable in echo command
  29. newton
  30. ulimit # get and set user limits
  31. # command and argument
  32. cal 2020 # command: cal, argument: 2020
  33. * Passing an argument to the command alters its behavior.
  34. * Some commands may require obligatory arguments and will return an error
  35. message if they are missing. For example, the command to copy a file needs
  36. two arguments: what file to copy, and where to copy it.
  37. * All commands can be modified using options that are specific to each command.
  38. cal -j # use option -j to display Julian calendar
  39. leave 2005 # to remind yourself to leave at 08:05 pm
  40. mkdir Directory; cd Directory; touch 1.txt 2.txt 3.c
  41. echo *.txt
  42. 1.txt 2.txt
  43. echo *
  44. 1.txt 2.txt 3.c
  45. rm -rf Directory
  46. mkdir -p dir1/dir2/dir3 # will create directories and its parent directories
  47. rm -rf dir1 # recursively deletes the contents of dir1 and its sub-directories
  48. # verify electronic mail addresses
  49. vrfy user@example.edu # verify that the email address user@example.edu valid
  50. # type
  51. type -a pwd
  52. IBM Developer
  53. https://developer.ibm.com/technologies/
  54. Learn Linux, 101:A road-map for LPIC-1
  55. https://developer.ibm.com/tutorials/l-lpicl-map/
  56. http://www.research.ibm.com/haifa/ponderthis/challenges/October2019.html
  57. http://www.brendangregg.com/index.html # perf tutorials
  58. # boot time check in Linux
  59. systemd-analyze
  60. systemd-analyze blame
  61. sudo systemctl disable NetworkManager-wait-online.service
  62. sudo systemctl enable NetworkManager-wait-online.service
  63. A repository is a collection of files that has information about various
  64. software, their versions and some other details like the checksum. Each Ubuntu
  65. version has its own official set of four repositories:
  66. Main - Canonical-supported free and open-source software
  67. Universe - Community-maintained free and open-source software
  68. Restricted - Proprietary drivers for devices
  69. Multiverse - Software restricted by copyright or legal issues
  70. /bin - Binaries, programs used in booting the system.
  71. /usr/bin - User binaries, standard programs available to users.
  72. /usr/local/bin - Local binaries, programs specific to an installation.
  73. https://www.ubuntu.com/about/release-cycle
  74. https://www.kernel.org/doc/man-pages/
  75. https://clearlinux.org/documentation/clear-linux
  76. # free and df
  77. free -h # RAM memory
  78. df -h # Hard Drive memory
  79. # Generate a random password
  80. gpw () { openssl rand -base64 48 | cut -c1-${1}; }
  81. date +%s | sha256sum | base64 | head -c 32 ; echo
  82. < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
  83. openssl rand -base64 32
  84. tr -cd `[:alnum:]` < /dev/urandom | fold -w30 | head -n1
  85. < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6
  86. date | md5sum
  87. gpg --gen-random --armor 1 14
  88. pwgen 14 1
  89. Ref: https://www.howtogeek.com/howto/30184/10-ways-to-generate-a-random-
  90. password-from-the-command-line/
  91. journalctl -b | grep 'DMI:'
  92. dell supports LVFS https://fwupd.org/lvfs/ for some, but not all devices.
  93. Note: If you use systemd, read the journalctl man page. It may seem heavy-going
  94. at first, but it makes searching the system logs so much more effective.
  95. sudo lsblk # list block devices
  96. swapon --summary # to find information about your swap space
  97. cat /proc/swaps
  98. set -o # to display all shell options
  99. set -o noclobber # - (dash) for enabling
  100. set +o noclobber # + (plus) for disabling
  101. apt-show-versions # to list installed packages
  102. aptitude search ~E # list essential packages
  103. ## id
  104. $ id username # print real and effective user and group IDs
  105. ## installed packages
  106. $ apt list --installed | less
  107. $ apt list --installed | grep -i apache
  108. $ dpkg -l
  109. $ dpkg -l | grep -i apache
  110. $ dpkg -S $(which <command>)
  111. /var/log/apt/
  112. sudo less -N history.log
  113. /var/lib/dpkg/available # available packages
  114. /etc/init.d # Configuration of System V init under Debian GNU/Linux
  115. /etc/systemd # Configuration of Systemd
  116. /etc/default # some default files
  117. In systemd, unit files get packaged into
  118. /usr/lib/systemd/system, but if you want
  119. to replace the default with your own, you
  120. can put them in /etc/systemd/system and
  121. whatever is there will take precedence
  122. over the defaults.
  123. To limit the amount of CPU a process gets by dropping in a new unit
  124. configuration file to /etc/systemd/system and adding:
  125. [Service]
  126. CpuShares=200
  127. # To login in text mode
  128. vi /etc/default/grub
  129. replace "quiet splash" -> "text"
  130. sudo update-grub
  131. # To start XMonad
  132. startx /usr/bin/xmonad-session
  133. # To start dwm
  134. startx /usr/local/bin/dwm
  135. # To start without cursor
  136. startx -- -nocursor
  137. # To start qutebrowser
  138. cd qutebrowser
  139. .venv/bin/python3 -m qutebrowser
  140. :set zoom.default 67%
  141. :config-source # to recompile
  142. ctrl+T # new tab
  143. shift+j # move to next tab
  144. shift+k # move to previous tab
  145. D # close the current tab
  146. # man pages
  147. apropos partition
  148. man ascii
  149. $ ascii # to display ascii characters
  150. man hier
  151. man systemd.unit
  152. man systemd.service
  153. # ctrl
  154. ctrl+A - begining of shell command
  155. ctrl+E - end of shell command
  156. ctrl+H - delete a letter
  157. ctrl+W - delete a word
  158. ctrl+U - erase line before cursor
  159. ctrl+K - erase line after cursor
  160. ctrl+Y - reverse of ctrl+W, ctrl+U and ctrl+K
  161. ctrl+B - move backward by letter
  162. ctrl+F - move forward by letter
  163. ctrl+P - scrolls through previous command
  164. ctrl+N - scrolls through next command
  165. ctrl+R - searches for commands you've already typed
  166. # alt
  167. alt+B - move backward by word
  168. alt+F - move forward by word
  169. alt+U - uppercase a word
  170. alt+L - lowercase a word
  171. alt+C - capitalizes letter where cursor is and moves to end of word
  172. # Special key strokes
  173. ctrl-U erase line before cursor
  174. ctrl-H erase a character before cursor
  175. ctrl-D terminate input (exit shell if you are using shell)
  176. ctrl-C terminate a running program
  177. ctrl-Z temporarily stop program by moving it to the background job
  178. ctrl-S halt output to screen
  179. ctrl-Q reactivate output to screen
  180. ctrl-Alt-Del reboot/halt the system, see inittab(5)
  181. Left-Alt-Key meta-key for Emacs and the similar UI
  182. Up-arrow start command history search under bash
  183. ctrl-R start incremental command history search under bash
  184. Tab complete input of the filename to the command line under bash
  185. ctrl-V Tab input Tab without expansion to the command line under bash
  186. # shutdown
  187. shutdown -h now
  188. shutdown -r now
  189. # Groups
  190. groups # to list the groups
  191. groups username # to list the groups to which the user belongs
  192. Note: Please bear in mind that the user ID of root is always 0 -every user
  193. with a user ID of 0 has root privileges!
  194. # sudo
  195. sudo -u username program # in sudoers you can permit the user to only sudo to
  196. that user and run that one program
  197. # Documents
  198. /usr/share/doc
  199. # whereis - to find the binary files
  200. whereis python3
  201. # alias
  202. alias
  203. alias ec='echo'
  204. unalias ec # to unalias the command
  205. note: enter it in .bashrc file (source ~/.bashrc)
  206. # information regarding the OS installed
  207. cat /etc/*release
  208. cat /etc/issue.net # to view Linux distribution
  209. lsb_release -a
  210. # Bash
  211. source ~/.bashrc # to compile changes in .bashrc file
  212. (to execute your .bashrc with source ~/.bashrc)
  213. ~/.bash_history # bash history file
  214. ~/.local/share/Trash #files in trash folder
  215. cp -r directory/ foo/ # copy recursively
  216. du -Sh # list all files size in directory
  217. du -sh # list only the file size of directory
  218. dpigs -H --lines=3000 | less -N
  219. ip addr list wlan0
  220. hostname -I # show ip address
  221. last - show a listing of last logged in users
  222. !! - alias to previous command
  223. # Adding/Deleting Users
  224. adduser username
  225. deluser username
  226. ## su command
  227. The su command is used to switch to a different user's account. You can use
  228. this command with the username of another user to log in with that user's
  229. session.
  230. $ su username
  231. To exit anytime from the other user's session just type exit and hit enter.
  232. # file
  233. file <filename> # displays the file type
  234. file -i <filename> # to get the mimetype
  235. # You can obtain detailed information on the hardware using ls commands such as
  236. lspci - list all PCI devices
  237. lsblk - list block devices
  238. lscpu - display information about the CPU architecture
  239. lsscsi - display SCSI devices information
  240. # hardware identification
  241. For the PCI-like devices (AGP, PCI-Express, CardBus, ExpressCard, etc.), lspci
  242. (probably with "-nn" option) is a good start for the hardware identification.
  243. Alternatively, you can identify the hardware by reading contents of
  244. "/proc/bus/pci/devices" or browsing directory tree under "/sys/bus/pci"
  245. pciutils - Linux PCI utilities: lspci
  246. usbutils - Linux USB utilities: lsusb
  247. pcmciautils - PCMCIA utilities for Linux: pccardctl
  248. scsitools - collection of tools for SCSI hardware management: lsscsi
  249. procinfo - system information obtained from "/proc": lsdev
  250. lshw - information about hardware configuration: lshw
  251. discover - hardware identification system: discover
  252. # system and hardware time
  253. The following sets system and hardware time to MM/DD hh:mm, CCYY.
  254. # date MMDDhhmmCCYY
  255. # hwclock --utc --systohc
  256. # hwclock --show
  257. If the hardware (BIOS) time is set to UTC, change the setting to "UTC=yes" in
  258. the "/etc/default/rcs".
  259. The following reconfigure the timezone used by the Debian system.
  260. # dpkg-reconfigure tzdata
  261. # NTP
  262. If you wish to update system time via network, consider to use the NTP service
  263. with the packages such as ntp, ntpdate, and chrony.
  264. Under systemd, use systemd-timesyncd for the network time synchronization
  265. instead.
  266. ntptrace in the ntp package can trace a chain of NTP servers back to the
  267. primary source
  268. ## keyboard
  269. sudo dpkg-reconfigure keyboard-configuration
  270. The keyboard type on the first screen will likely be correct ("Generic") then
  271. when you hit OK (Enter) the other screens will prompt you for language etc. Use
  272. arrow keys to scroll up and down between options and "Enter" for OK.
  273. # systemd is the most popular init process for bootstrapping user spaces and
  274. controlling multiple system process.
  275. sudo systemctl status
  276. # Dmesg allows you to figure out errors and warnings in the kernel's latest
  277. messages.
  278. dmesg | less
  279. # You can also look at all Linux system logs in the /var/log/messages file,
  280. which is where you'll find errors related to specific issues. It's worthwhile
  281. to monitor the messages via the tail command in real time when you make
  282. modifications to your hardware, such as mounting an extra disk or adding an
  283. Ethernet network interface.
  284. tail -f /var/log/messages
  285. # Commands to figure out networking functions in the Linux server include
  286. ip addr, traceroute, nslookup, dig, and ping, among others.
  287. sudo ip addr show
  288. To mount cd to /home/user/lan :
  289. sudo mount /dev/cdrom /home/user/lan
  290. # chmod
  291. chmod u=rwx,g=rwx,o=rwx <filename>
  292. chmod 777 <filename>
  293. 4=read, 2=write, 1=execute, 0=no permission
  294. 7=4+2+1 5=4+0+1 4=4+0+0
  295. chmod 600 <filename> # make an existing file "<filename>" to be non-readable
  296. and non-writable by the other people
  297. (non-executable for all)
  298. chmod 644 <filename> # make an existing file "<filename>" to be readable but
  299. non-writable by the other people
  300. (non-executable for all)
  301. chmod 755 <filename> # make an existing file "<filename>" to be readable but
  302. non-writable by the other people (executable for all)
  303. u user + to add a permission r read
  304. g group - to remove a permission w write
  305. o other = to assign a permission explicitly x execute (for files),
  306. chmod u=rw file
  307. sets the permissions on the file to give the user read and write permission on
  308. file. No other permissions are altered.
  309. chmod u+x,g+w,o-r file
  310. alters the permissions on the file to give the user execute permission, to
  311. give members of the users group write permission, and prevent any users not
  312. in the group from reading it.
  313. chmod u+w, go-x dir
  314. gives the user write permission in the dir, and prevents all other users
  315. having access to that directory (by using cd. They can still list its
  316. contents using ls.)
  317. chmod a+w file # to add write access for everybody
  318. chmod a-w file # to remove write access
  319. chmod a=r file # set permissions on the file to allow
  320. only read access for all users
  321. chmod u+w, go+r-w file # adds write access for the file owner and removes
  322. write access and adds read access for the group
  323. and other classes
  324. chmod -R go-rwx /home/user # if user wants to protect all the files under
  325. his home directory from everyone else
  326. [recursive option (-R)]
  327. chmod -R +r . # grants read access to all users for the current
  328. directory and every file under it
  329. chmod go= file # prevents any access to the file by anyone other
  330. than its owner
  331. chmod go+rX * # the X access type grants execute access to the
  332. specified access classes only when execute access
  333. is already set for some access class. A typical
  334. use for this access type is to grant group or
  335. other read and execute access to all the
  336. directories and executable files within a
  337. subtree while granting only read access to all
  338. other types of files (example: datafile.txt)
  339. chmod o=g * # makes the other access the same as the current
  340. group access for each file/directory
  341. # umask
  342. 027 is better from security perspective, even better is to use 077 for root.
  343. With 027 mask, when root creates a file, it can be read and executed by users
  344. who belongs to the group of the file. With 077 mask, only root can read write
  345. and execute files.
  346. Why is 077 better?
  347. because by making files belonging to user readable by root only, it avoids some
  348. common system administrator mistakes. because it's harder for an attacker to
  349. run privilege escalation only poorly written shell scripts/binaries if they
  350. can't even read it.
  351. # chown
  352. chown user file/Directory # Change the owner of fiel/Directory to "user"
  353. chown user:staff file/Directory # Likewise but also change its group to "staff"
  354. chown -hR user file/Directory # Change the owner of file/Dire and subfiles
  355. Note: refer man chown (Examples section)
  356. # chgrp
  357. chgrp user file/Directory # Change the group of file/Directory to "user"
  358. chgrp -hR user file/Directory # Change the group of file/Dire and subfiles
  359. Note: refer man chgrp (Examples section)
  360. # irssi - https://freenode.net/kb/answer/registration
  361. https://irssi.org/documentation/startup/
  362. https://wiki.debian.org/IRC
  363. https://fedoraproject.org/wiki/How_to_use_IRC#Meeting_Protocol
  364. Help regarding registration - /msg NickServ help register
  365. Register your IRC nick - /msg NickServ REGISTER password youremail@example.com
  366. Logging in - /connect chat.freenode.net 6667/6697 account_name:password
  367. /help # show all commands
  368. /help command # shows command usage
  369. /network list # list network
  370. /connect Freenode # connect network Freenode
  371. /join #debian # join channel debian
  372. /part # leave channel
  373. /nick name # changes the name
  374. /whois name # shows basic whois info for a name
  375. /msg NickServ info name # more info of /whois name
  376. /away message # leaves a message when you are away frm channel
  377. /back # use /back when you return
  378. /quit message # leaves a message when you quit IRC channel
  379. long pastes: wgetpaste or dpaste.com
  380. For posting multi-line texts into the channel - https://paste.ubuntu.com
  381. To post screenshots use https://imgur.com/
  382. !pastebinit to paste directly from command line
  383. Make sure you give us the URL for your paste
  384. # wireless connection - wlx00873239946f
  385. sudo ifconfig wlan0 up/down # bring wireless network up/down
  386. iw dev # gives wifi adapter device name
  387. iw wlan0 link # Connected/Not Connected
  388. (wlan0 - device name from previous command)
  389. sudo iw wlan0 scan / sudo iwlist wlan0 scan
  390. nmcli dev
  391. nmcli dev wifi
  392. sudo nmcli dev wifi connect name password *****
  393. (replace name with network name)
  394. nmcli con show = nmcli -p connection
  395. (list all ethernet and wireless connections)
  396. # nmcli
  397. nmcli connection show # list all network connections
  398. nmcli device show # list device information including hardware address
  399. nmcli general status # show overall status of Network Manager
  400. nmcli general hostname # get and change system hostname
  401. nmcli general permissions # show the permissions
  402. nmcli general logging # get and change Network Manager logging level
  403. and domains
  404. nmcli networking on/off # enable or disable networking control by
  405. Network Manager
  406. nmcli networking connectivity # get network connectivity state
  407. none = the host is not connected to any network
  408. portal = the host is behind a captive portal and cannot reach the full Internet
  409. limited = the host is connected to a network, but it has no access to Internet
  410. full = the host is connected to a network and has full access to the Internet
  411. unknown = the connectivity status cannot be found out
  412. nmcli radio all/wifi/wwan
  413. nmcli radio wifi on/off
  414. nmcli radio wwan on/off
  415. nmcli radio all on/off
  416. nmcli monitor # observe Network Manager activity
  417. nmcli connection show/up/down/add/edit/modify/delete/monitor/reload/load
  418. nmcli dev status/show/set/connect/reapply/disconnect/delete/monitor/wifi/lldp
  419. nmcli -p -f general,wifi-properties device show wlx00873239946f # dev details
  420. man 7 nmcli-examples -- usage examples of nmcli
  421. # mount/unmount usb
  422. fdisk -l (sudo) #to find name
  423. df -h
  424. /dev/sdb1
  425. sudo mount /dev/sdb1 /media/user
  426. sudo umount /dev/sdb1 /media/user
  427. # undo cannot format on usb storage
  428. - type sudo fdisk -l and not usb drive letter (/dev/sdb1)
  429. - make sure the device is unmount
  430. - type sudo fdisk /dev/sdb
  431. - type d to proceed to delete a partition
  432. - type 1 to select the 1st partition and press enter
  433. - typd d to proceed to delete another partition
  434. (fdisk should automatically select the second partition)
  435. - type n to make a new partition
  436. - type p to make this partition primary and press enter
  437. - type 1 to make this the first partition and then press enter
  438. - press enter to accept the default first cylinder
  439. - press enter again to accept the default last cylinder
  440. - type w to write the new partition information to the USB key
  441. - type umount /dev/sdb1 (check)
  442. - type sudo mkfs.vfat -F 32 /dev/sdb1
  443. # for mkfs.vfat
  444. sudo apt-get install dosfstools
  445. /sbin/mkfs.vfat
  446. # Basic Network Commands
  447. ping www.slackware.com
  448. traceroute www.slackware.com
  449. host www.slackware.com #map name to ip address
  450. nslookup 64.57.102.34
  451. dig @192.168.1.254 www.slackware.com mx
  452. # text editor
  453. sudo update-alternatives --config editor
  454. # X terminal emulator
  455. sudo update-alternatives --config x-terminal-emulator
  456. # Recording the shell activities (record when you perform any sys admin tasks)
  457. $script #Script started, file is typescript
  458. Do whatever shell commands under script
  459. Press Ctrl-D to exit Script
  460. sudo apt purge `dpkg --get-selections | grep deinstall | cut -f1`
  461. aptitude search '?essential'
  462. # To list all essential packages in debian
  463. dpkg-query -Wf '${Package; -40}${Essential}\n' | grep yes
  464. # send message to everyone who is logged on to the system with wall
  465. echo "We are shutting down in 1 hour" | wall
  466. # viewing binary data
  467. od -t x1 <name>
  468. # To convert *.mkv to *.mp4
  469. ffmpeg -i input.mkv -codec copy output.mp4
  470. # pdftk (read man page of pdftk)
  471. pdftk in.pdf output out.pdf uncompress
  472. LESSOPEN="" less out.pdf
  473. merge multiple pdf files into a single document:
  474. pdftk file1.pdf file2.pdf cat output merged.pdf
  475. combine even and odd pages into one document:
  476. pdftk A=even.pdf B=odd.pdf shuffle A B output combined.pdf
  477. split a pdf file into multiple documents:
  478. pdftk input.pdf cat 1 output page1.pdf
  479. pdftk input.pdf cat 2-end output pages2-end.pdf
  480. rotate the pages of a pdf file:
  481. pdftk input.pdf cat 1east 2east 3-endwest output outfile.pdf
  482. This rotates the first and second pages of 'input.pdf' 90 degrees clockwise and
  483. the remaining pages 90 degrees counterclockwise.
  484. rotate all pages by 180 degrees:
  485. pdftk input.pdf cat 1-endS output outfile.pdf
  486. fill out a pdf form:
  487. pdftk form.pdf fill_form data.fdf output filled.pdf
  488. This fills out the form fields in 'form.pdf' using the data in the 'data.fdf'
  489. file and saves the result in 'filled.pdf'.
  490. # qpdf
  491. to combine two pdf files to form a new pdf file:
  492. qpdf --empty --pages file1.pdf file2.pdf -- combined.pdf
  493. using wildcards instead of listing many source files:
  494. qpdf --empty --pages *.pdf -- allcombined.pdf
  495. to extract pages 1 and 2 from file1.pdf and page 1 from file2.pdf:
  496. qpdf --empty --pages file1.pdf 1-2 file2.pdf 1 -- combined.pdf
  497. to extract pages from a large pdf file:
  498. qpdf --empty --pages largefile.pdf 1-3,7,11,18-21,55 -- summary.pdf
  499. The output file, 'summary.pdf' contains pages 1 to 3, 7, 11, 18 to 21, and 55
  500. from the input file 'largefile.pdf'.
  501. to split a pdf file into separate pdf files each holding a single page:
  502. qpdf summary.pdf page.pdf --split-pages
  503. The file we're splitting is 'summary.pdf', and the output file is given as
  504. 'page.pdf'. This is used as the base name. Each new file has a number added to
  505. the base name. The --split-pages option tells qpdf what type of action we're
  506. performing.
  507. use page ranges to select the pages you want to split:
  508. qpdf large.pdf section.pdf --pages large.pdf 1-5,11-14,60,70-100 -- --split-pages
  509. The page ranges are used to specify the pages/ranges we want, but each page is
  510. still stored in a single pdf file.
  511. to extract a page range and stored in a single pdf:
  512. qpdf --empty --pages large.pdf 8-13 -- chapter2.pdf
  513. to rotate a page, we use the --rotate option:
  514. qpdf --rotate=+90:1 summary.pdf rotated1.pdf
  515. The +90 means rotate the page 90 degrees clockwise. You can rotate a page 90,
  516. 180, or 270 degrees. You can also specify the rotation in degrees anticlockwise,
  517. by using a negative number, but there's little need to do so. A rotation of -90
  518. is the same as a rotation +270. The number separated from the rotation by a
  519. colon ':' is the number of the page you want to rotate. This could be a list of
  520. page numbers and page ranges, but we're just rotating the first page. To rotate
  521. all pages use a page range of 1-z.
  522. to create an encrypted version of the 'summary.pdf' called 'secret.pdf':
  523. qpdf --encrypt <user password> <owner password> 256 -- summary.pdf secret.pdf
  524. To encrypt a pdf we need to use the --encrypt option and provide both the user
  525. password and the owner password. We also specify the strength of encryption to
  526. use. You'd only need to drop from 256-bit encryption to 128-bit if you want to
  527. support very old pdf file viewers. We suggest to stick with 256-bit encryption.
  528. to decrypt a file:
  529. qpdf --decrypt --password=<owner password> secret.pdf unlocked.pdf
  530. To decrypt a file, use the --decrypt option. Obviously, you must know the owner
  531. password for this to work. We need to use the --password option to identify the
  532. password.
  533. Reference: https://qpdf.readthedocs.io/en/stable/index.html
  534. # scribus
  535. # cowsay
  536. cowsay -l
  537. cowsay -f tux Linux is awesome
  538. # ls
  539. List only the .txt files in the directory: ls *.txt
  540. List by file size: ls -a
  541. Sort by time and date: ls -d
  542. Sort by extension: ls -x
  543. Sort by file size: ls -S
  544. Long format with file size: ls -ls
  545. send it to a file for later viewing: ls -al > mydirectorylist
  546. # mkdir
  547. mkdir sa{1..50} # 50 directories from sa1 to sa50
  548. # tar files/directories to backup
  549. 1. Compress an Entire Directory or a Single file
  550. tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
  551. -c: Create an archive, -z: Compress the archive with gzip,
  552. -v: Display progress in the terminal while creating the archive
  553. -f: Allows you to specify the filename of the archive
  554. 2. Compress Multiple Directories or Files at once
  555. tar -czvf archive.tar.gz /home/ubuntu/Downloads /usr/local/stuff
  556. /home/ubuntu/Documents/notes.txt
  557. 3. Exclude Directories and Files
  558. tar -czvf archive.tar.gz /home/ubuntu --exclude=/home/ubuntu/Downloads
  559. --exclude=/home/ubuntu/.cache
  560. tar -czvf archive.tar.gz /home/ubuntu --exclude=*.mp4
  561. 4. Use bzip2 Compression Instead
  562. tar -cjvf archive.tar.bz2 stuff
  563. 5. Extract an Archive
  564. tar -xzvf archive.tar.gz
  565. 6. Extract the contents of the archive to a specific directory
  566. tar -xzvf archive.tar.gz -C /tmp
  567. # untar/tar
  568. tar -tf *.tar.gz # to view contents without extracting
  569. tar -tvf *.tar.gz # list more information
  570. tar -xvzf filename.tar.gz # to decompress a tarball
  571. # zip
  572. unzip -l filename.zip # to view contents without unzip
  573. unzip filename.zip # to unzip
  574. # scp
  575. scp ph15m015@172.29.204.101:/home2/mtech/ph15m015/cl.tar.gz .
  576. # hostname
  577. hostname # list machine name
  578. hostname -i # list 127.0.1.1
  579. hostname -I # list ip address of network
  580. # youtube-dl [http://ytdl-org.github.io/youtube-dl/download.html]
  581. To install it right away for all UNIX users type:
  582. $ sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
  583. $ sudo chmod a+rx /usr/local/bin/youtube-dl
  584. If you do not have curl, you can alternatively use wget:
  585. $ sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
  586. $ sudo chmod a+rx /usr/local/bin/youtube-dl
  587. :yank # type :yank in qutebrowser to copy the url
  588. xclip -o -selection clipboard > url.txt # write the url in url.txt
  589. youtube-dl --extract-audio/-x --audio-format mp3 "$(< url.txt)" # mp3 format
  590. youtube-dl -F "$(< url.txt)" # to find best video format
  591. youtube-dl -F --no-playlist "$(< url.txt)" # list available formats of one file
  592. youtube-dl -f no. "$(< url.txt)" # to download the file
  593. youtube-dl -f 22 --no-playlist -f 22 --no-playlist "$(< url.txt)"
  594. # update youtube-dl
  595. sudo youtube-dl --update
  596. # version
  597. youtube-dl --version
  598. # SSH
  599. If you're using a cloud server, you will probably want to allow incoming SSH
  600. connections (port 22) so you can connect to and manage your server. This
  601. section covers how to configure your firewall with various SSH-related rules.
  602. Allow SSH
  603. To allow all incoming SSH connections run this command:
  604. $ sudo ufw allow/deny ssh
  605. An alternative syntax is to specify the port number of the SSH service:
  606. $ sudo ufw allow 22
  607. Allow incoming SSH from specific IP Address or Subnet
  608. To allow incoming SSH connections from a specific IP address or subnet,
  609. specify the source. For example, if you want to allow the entire 15.15.15.0/24
  610. subnet, run this command:
  611. $ sudo ufw allow from 15.15.15.0/24 to any port 22
  612. Allow incoming Rsync from specific IP Address or Subnet Rsync, which runs on
  613. port 873, can used to transfer files from one computer to another.
  614. To allow incoming rsync connections from a specific IP address or subnet,
  615. specify the source IP address and the destination port. For example, if you
  616. want to allow the entire 15.15.15.0/24 subnet to be able to rsync to your
  617. server, run this command:
  618. $ sudo ufw allow from 15.15.15.0/24 to any port 873
  619. Source: https://www.digitalocean.com/community/tutorials/ufw-essentials-common
  620. -firewall-rules-and-commands
  621. https://thepcspy.com/read/making-ssh.secure/
  622. # hardware info
  623. hwinfo --help
  624. hwinfo --netcard
  625. hwinfo --gfxcard
  626. # dpkg commands
  627. # to install a downloaded debian package (.deb)
  628. sudo dpkg -i packagename.deb
  629. # to unpack the package (.deb) without installing it
  630. sudo dpkg --unpack packagename.deb
  631. # to remove a debian package (.deb)
  632. sudo dpkg -r packagename
  633. # to purge a debian package (.deb)
  634. sudo dpkg -P packagename
  635. # to reconfigure/repair an installed debian package
  636. sudo dpkg-reconfigure packagename
  637. # find out what package the file /etc/logrotate.conf belongs
  638. dpkg -S /etc/logrotate.conf
  639. # list information about the pkg including all the files it contains
  640. dpkg -L packagename
  641. # verify the package installation
  642. dpkg -V packagename
  643. # information about .deb package
  644. dpkg --info *.deb
  645. # report status of specified package
  646. dpkg --status packagename
  647. # list all currently installed packages (including those from the repositories)
  648. dpkg -l
  649. # if you need simpler output
  650. dpkg --get-selections
  651. # display details of the specified package
  652. dpkg -s zip
  653. # clamAV
  654. sudo apt install clamav
  655. sudo freshclam # to update the signatures
  656. clamscan --help
  657. clamscan -r --bell -i /home/username/Downloads
  658. # lynis
  659. sudo lynis audit system
  660. sudo lynis audit system --quick
  661. sudo lynis show commands
  662. sudo lynis show help
  663. sudo lynis show profiles
  664. sudo lynis show settings
  665. sudo lynis show version
  666. Reference:
  667. https://cisofy.com/documentation/lynis/get-started/#first-run
  668. https://linuxsecurity.expert/checklists/linux-security-and-system-hardening
  669. https://linuxsecurity.expert/checklists/linux-security-best-practices
  670. Installation:
  671. git clone https://github.com/CISOfy/lynis
  672. Execute:
  673. cd lynis
  674. ./lynis audit system
  675. To run as root, change ownership of the related files (or full directory)
  676. chown -R 0:0 lynis
  677. Test and debug information: /var/log/lynis.log
  678. Report data : /var/log/lynis-report.dat
  679. # ps_mem
  680. sudo pip install --upgrade pip # to upgrade pip to latest version
  681. sudo pip install ps_mem
  682. sudo ps_mem | less # to run ps_mem
  683. # Private Browsing using Tor and I2P
  684. Tor, I2P, etc, are open, distributed networks that bounce your internet
  685. communications around a network of relays run by volunteers all around the
  686. world. This way, anybody watching your internet connection can't figure out the
  687. sites you visit, and the sites you visit can't track your physical location.
  688. Though both of them are supposed to protect your identity online using
  689. cryptographic methods, there are several differences in their respective
  690. approaches to this question of privacy. Tor takes the directory-based approach,
  691. providing a centralised point to manage the overall view of the network, as
  692. well as gather and report statistics, while I2P uses a distributed network
  693. database and peer selection. Tor provides better anonymous access to the open
  694. internet while I2P provides a more tobust and reliable network within the
  695. network layout. Tor also has a larger user base, with more volunteers around
  696. the world.
  697. Also, beware that your ISP can see that you're using Tor or I2P (though they
  698. cannot determine the content of the traffic). To hide this information from
  699. your ISP, you can use a high-quality VPN service to act as an entry point to
  700. your anonymous network. An excellent open source project for this is OpenVPN:
  701. https://openvpn.net
  702. # Tlp
  703. sudo tlp-stat | less # system info
  704. # Service - /etc/init.d
  705. service --status-all # to list status of all services
  706. service sshd status # gives the status of sshd
  707. service sshd stop # to stop the sshd service
  708. service sshd start # to start the sshd service
  709. service sshd restart # to restart the sshd service
  710. # wget
  711. If you ever need to download an entire website, perhaps for off-line viewing,
  712. wget can do the job for you:
  713. $ wget \
  714. --recursive \ # download the entire website
  715. --no-clobber \ # don't overwrite any existing files
  716. --page-requisites \ # get all the elements that compose the page (images, css)
  717. --html-extension \ # save files with the .html extension
  718. --convert-links \ # convert links so that they work locally, off-line
  719. --restrict-file-names=windows \ # modify filename (to work in windows as well)
  720. --domains website.org \ # don't follow links outside website.org
  721. --no-parent \ # don't follow links outside the directory tutorials/html/
  722. www.website.org/tutorials/html/
  723. wget resume download
  724. wget -c url
  725. wget --continue url
  726. wget --continue [options] url
  727. man wget
  728. wget --help
  729. wget address
  730. wget --http-user=USER --http-password=PASSWORD address
  731. # download an entire website
  732. $ wget --random-wait -t -p -e robots=off -U mozilla https://www.website.com
  733. # curl
  734. curl web-address > file-source
  735. example: curl https://address.html > address.html
  736. curl ipinfo.io/ip_addr
  737. curl https://api.ipdata.co/ip_addr?api-key=test
  738. curl https://ipapi.co/ip_addr/json
  739. # trickle
  740. trickle -d 1024 wget -c
  741. https://archive.org/download/CharlieChaplin/Chaplin_512kb.mp4
  742. will download the Charlie Chaplin movie (available as public domain from the
  743. Internet Archive) with the Wget downloader limiting the download speed to
  744. 1024 Kbps.
  745. You can use Wget's --limit-rate option to regulate its download speed.
  746. In the same vein, use the -u switch to regulate the upload speed.
  747. If setting per-application speeds seems too much of a chore, you can set global
  748. speed caps with the trickled command, such as
  749. trickled -d 2048 -u 1024
  750. trickle apt upgrade
  751. will now update the Ubuntu installation while respecting the limits set by the trickled.
  752. # httrack
  753. # tasksel - a user interface for installing tasks
  754. tasksel --list-tasks
  755. tasksel --task-packages dns-server # to list the packages installed
  756. with the DNS server
  757. # Terminal:
  758. sudo update-alternatives --list x-terminal-emulator
  759. sudo update-alternatives --install /usr/bin/x-terminal-emulator
  760. x-terminal-emulator /usr/bin/stterm 100
  761. sudo update-alternatives --list x-terminal-emulator
  762. sudo update-alternatives --config x-terminal-emulator
  763. # Hardware Info
  764. sudo lshw | less
  765. sudo lshw -C network
  766. # APT commands reference
  767. apt-cache pkgnames
  768. apt-cache search <package-name>
  769. apt-cache --names-only search chm
  770. apt-cache show <package-name>
  771. apt-cache showpkg <package-name> # show dependencies
  772. apt-cache depends <package-name>
  773. apt-cache rdepends <package-name>
  774. apt-cache depends --installed <package-name>
  775. apt-cache rdepends --installed <package-name>
  776. apt-cache stats
  777. doas apt-get update / doas apt update
  778. doas apt-get upgrade / doas apt upgrade / doas apt-get dist-upgrade
  779. doas apt-get install <package-name> / doas apt install <package-name>
  780. doas apt-get install <package-name1> <package-name2>
  781. doas apt list # to list all available packages
  782. doas apt list | grep <package-name>
  783. doas apt list --installed # to list only the installed packages
  784. doas apt list --upgradable # to list of the upgradable packages before upgrading
  785. apt search <package-name> # to search for a given package in the list of packages
  786. apt show <package-name> # to retrieve information about a given package
  787. doas apt autoremove # to remove the unneeded dependencies
  788. doas apt remove <package-name> # to remove an installed package
  789. doas apt purge <package-name> # to remove an installed package including config files
  790. doas apt update # to update the package index (pull latest changes from APT repo)
  791. doas apt upgrade # to upgrade the installed packages to their latest versions
  792. doas apt upgrade <package-name> # to upgrade <package-name>
  793. doas apt full-upgrade # will remove the installed packages if needed to upgrade
  794. doas apt install <package-name> # install <package-name>
  795. doas apt install <package-name1> <package-name2>
  796. doas apt install /path/to/file.deb # to install local deb.file
  797. Note:
  798. * apt combines the most frequently used commands from the apt-get and apt-cache
  799. tools with different default values of some options
  800. * apt is designed for interactive use
  801. * prefer using apt-get and apt-cache in shell scripts as they are backward compatible
  802. between the different versions and have more options and features
  803. * always update the package index before upgrading or installing new packages
  804. * upgrade command doesn't upgrade packages that require removal of installed packages
  805. * the difference between upgrade and full-upgrade is that the later will remove
  806. the installed packages if that is needed to upgrade the whole system
  807. # apt-get update/upgrade list without changing anything
  808. apt list --upgradable
  809. apt-get --simulate upgrade
  810. apt-get -s upgrade # --simulate, --just-print, --dry-run, --recon, --no-act
  811. doas apt-get -u upgrade --assume-no
  812. doas apt-get -u -V upgrade # to list packages to be upgraded with their versions
  813. doas apt-get --only-upgrade install <package-name>
  814. # apt-show-versions
  815. apt-show-versions # to know for all your installed packages whether they are
  816. uptodate or upgradeable
  817. apt-show-versions -u # if you want to have a list of all upgradeable packages
  818. apt-show-versions -a -p libc6 # to get list of all available versions of libc6
  819. apt-show-versions dpkg apt # to get information about several packages
  820. apt-show-versions -r ^texlive
  821. apt-get install `apt-show-versions -u -b | grep testing` # to upgrade all packages in
  822. testing
  823. -u, --upgradeable # Print only upgradeable packages
  824. -a, --allversions # Print all available versions of the selected packages
  825. -b, --brief # Print only package_name/distribution for upgradeable packages
  826. -v, --verbose # Prints out messages about which package files are parsed
  827. -V, --version # Prints out version of apt-show-versions
  828. -h, --help # Prints out command-line help
  829. # To decrypt file
  830. qpdf -password=password -decrypt /home/username/Documents/Secured.pdf
  831. /home/username/Documents/unsecured.pdf
  832. # xrandr
  833. xrandr --listmonitors # this command gives the <output name>
  834. for the command below
  835. xrandr --output <output name> --brightness "<x>"
  836. ## <x> is a number between 1 (full brightness) and 0 (backlight off)
  837. # rclone - a command line program to sync files and directories
  838. # List directories in top level of your pCloud
  839. rclone lsd remote:
  840. # List all the files in your pCloud
  841. rclone ls remote:
  842. # To copy a local directory to remote:backup
  843. rclone copy /home/source remote:backup
  844. # To sync a local directory to a remote
  845. rclone sync /home/source remote:directory_name
  846. rclone sync -P /home/source remote:directory_name # -P progress
  847. rclone sync -P Books/Chess/chess-wikibooks.pdf pcloud:Books/Chess/
  848. rclone sync /home/source remote:directory_name --dry-run
  849. rclone move /home/source remote:directory_name
  850. rclone delete remote:path
  851. # checks the files in the source and dest match
  852. rclone check source:path dest:path
  853. rclone check /home/saran/Books pcloud:Books/
  854. # To create a directory in remote
  855. rclone mkdir remote:directory_name
  856. # prints the total size and number of objects in remote:path
  857. rclone size remote:path
  858. # interactively find duplicate files and delete/rename them
  859. rclone dedupe remote:path
  860. rclone version
  861. rclone version --check
  862. # get quota information from the remote
  863. rclone about remote:
  864. rclone config file
  865. rclone config show
  866. rclone config providers
  867. # list all the remotes in the config file
  868. rclone listremotes
  869. # Mount the remote as file system
  870. rclone mount remote:path/to/files /path/to/local/mount
  871. # Explore a remote with a text based user interface
  872. rclone ncdu remote:
  873. # create new file or change file modification time
  874. rclone touch remote:path
  875. # list the contents of the remote in a tree like fashion
  876. rclone tree remote:path
  877. rclone move remote:GRE remote:Books/GRE/
  878. # IP
  879. sudo ip addr show # to check an IP address
  880. sudo ip addr del 192.168.50.5/24 dev eth1 # to remove an IP address
  881. sudo ip link set eth1 up # to enable network interface
  882. sudo ip link set eth1 down # to disable network interface
  883. sudo ip route show # to check route table
  884. *** https://www.tecmint.com/red-hat-rhcsa-rhce-exam-certification-book/
  885. # systemctl
  886. systemctl status ufw # to check the status of ufw
  887. # journald
  888. sudo journalctl -b # log messages right from the system boot
  889. # fdisk http://www.slackware.com/install/partitions.php
  890. When you start fdisk you need to specify the device to use. By default it will
  891. try to open /dev/hda, but in some cases this is not the correct device to use.
  892. Just specify the device name after typing fdisk on the command line.
  893. For example:
  894. fdisk /dev/hdb
  895. This will tell fdisk to open the primary slave IDE hard disk. Notice that you
  896. do not specify a partition number on the device name.
  897. An alternative to fdisk is cfdisk, which provides a menu-based setup program
  898. for the partition setup (DOS users comfortable with DOS's fdisk may find this
  899. program easier).
  900. Just run cfdisk at the prompt instead of fdisk.
  901. Here are some key commands you should be familiar with when using fdisk.
  902. p Display the current partition table
  903. m Display the help screen
  904. d Delete a partition
  905. n Add a new partition
  906. t Change the partition's system ID
  907. q Quit fdisk without saving changes
  908. w Write changes to device and quit fdisk
  909. # w3m
  910. sudo apt install w3m w3m-img # installing w3m
  911. w3m duckduckgo.com # basic browsing
  912. shift-B # take you back a page
  913. shift-T # browser tabs
  914. shift-[ and shift-] # to switch between tabs
  915. Esc + A # to bookmark the page
  916. w3m -M <url> # Display web content in monochrome terminal
  917. w3m -o auto_image=TRUE # Display embedded graphics
  918. # Display content from Usenet
  919. w3m -m nntp://news.aioe.org/comp.os.linux.networking
  920. # Upload data for a URL using the POST method
  921. w3m -post - http://example.com/form.php <<<'a=0&b=1'
  922. ~/.w3m/bookmark.html # default bookmark file
  923. ~/.w3m/config # user defined configuration file; orverrides /etc/w3m/config
  924. ~/.w3m/cookie # cookie jar; written on exit, read on launch
  925. ~/.w3m/history # browser history -visited files and URLs
  926. ~/.w3m/keymap # user defined key bindings; overrides default key bindings
  927. ~/.w3m/mailcap # external viewer configuration file
  928. ~/.w3m/menu # user defined menul overrides default menu
  929. ~/.w3m/mime.types # MIME types file
  930. ~/.w3m/mouse # user defined mouse settings
  931. ~/.w3m/passwd # password and username file
  932. ~/.w3m/pre_form # contains predefined values to fill recurrent HTML forms
  933. http://w3m.sourceforge.net
  934. Translate html to text
  935. cat index.html | w3m -dump -T text/html > index.txt
  936. Useful command line options
  937. -s squeeze multiple blank lines
  938. -cookie
  939. -no-proxy
  940. -post FILE
  941. Moving around
  942. H show runtime options
  943. K,J scroll one line
  944. .,, shift screen by one column
  945. z center current line
  946. [,] go to first/last link
  947. TAB move to next link
  948. C-u,ESC-TAB move to previous link
  949. C-m popup link list menu and move cursor to selected link
  950. C-l popul link list menu and go to selected link
  951. (,) cancel/redo last cursor movement
  952. Hyperlinks
  953. C-t open link in new tab
  954. a save link
  955. c peek current URL
  956. u peek link URL
  957. I view image
  958. ; mark current word as anchor (link navigation will apply)
  959. = view info of current document
  960. F render frame
  961. L show all links and images
  962. Buffers
  963. B back
  964. v view HTML source
  965. s popup buffer selection menu
  966. S save buffer to file
  967. E edit current document (local file)
  968. R reload
  969. + information about current page
  970. Tabs
  971. T open new tab
  972. C-q close current tab
  973. {,} move to next/previous tab
  974. ESC-t popup tab selection menu
  975. Bookmarks
  976. ESC-b view bookmark
  977. ESC-a add current page to bookmark
  978. Search
  979. /,? search forward/backward
  980. C-s,C-r incremental search forward/backward
  981. Marks
  982. C-@ set/unset mark
  983. ESC-n,ESC-p move to next/preious mark
  984. Misc
  985. o option setting panel
  986. C-k view cookie list
  987. C-h view history
  988. ! execute shell command
  989. C-z stop loading document
  990. Q quit without confirmation
  991. # system information viewers
  992. dmidecode - it reports information about your system's hardware as described
  993. in your system BIOS according to the SMBIOS/DMI standard.
  994. hwinfo - powerful hardware detection tool come from openSUSE
  995. inxi - a script to get system information
  996. nmon - console based application for monitoring various system components
  997. # Apache
  998. To look into the number of Apache processes your Linux system runs:
  999. ps ax | grep apache | grep -v grep | wc -l
  1000. The relevant information is kept inside the Apache configuration file:
  1001. /etc/apache2/apache2.conf
  1002. # Server query
  1003. host www.slackware.com
  1004. dig www.slackware.com
  1005. nslookup www.slackware.com
  1006. # Manage processes
  1007. When an executable program starts up, it runs a process and this process will
  1008. be under the management of your Linux system's process table.
  1009. The ps and top commands are very powerful for viewing information about the
  1010. running processes. Then there are commands such as nice and renice and they
  1011. can be used for raising and lowering the process's priority. You can also move
  1012. the processes to run in the background, or back to run in the foreground again.
  1013. A command -chrt- can be used to run processes in real-time. You can use the
  1014. kill and killall commands to send signals to processes by PID or by name.
  1015. The ps command gives a snapshot of currently running processes whereas the
  1016. top command offers a screen-oriented, constantly updated listing of the
  1017. running commands.
  1018. ps # displays the list of processes of the current user at the current shell
  1019. ps -u username # specific user's running process
  1020. ps -u username u # displays all the running processes with CPU and memory info
  1021. ps -e # displays every running process
  1022. ps -el # long list of every running process
  1023. ps -ef # displays a full format list of all running processes
  1024. ps -eF # extra full format list of all running processes
  1025. Some processes start up other processes. The hierarchy of processes can be
  1026. viewed by using several options witht the ps command.
  1027. # shows the process hierarchy with information on process and session IDs.
  1028. ps -ejH
  1029. # default delay to update is 3 seconds; this command changes it to 5 seconds
  1030. top -d 5
  1031. # view only the processes related to the specific user
  1032. top -u username
  1033. # this will refresh the screen ten times before quitting
  1034. top -n 10
  1035. # run in batch mode
  1036. top -b
  1037. # exiftool
  1038. # to read the entire history of an image
  1039. exiftool filename.jpg
  1040. # to scrub all the personalizing metadata from the image
  1041. exiftool "-all=" filename.jpg
  1042. # to read the entire history of an mp3 file
  1043. exiftool filename.mp3
  1044. exiftool filename.pdf
  1045. # ffmpeg
  1046. ffmpeg -i filename.mp3/filename.mp4 # to read entire history
  1047. # xmonad
  1048. --recompile Recompiles your configuration in ~/.xmonad/xmonad.hs
  1049. --restart Causes the currently running xmonad process to restart
  1050. --replace Replace the current window manager with xmonad
  1051. --version Display version of xmonad
  1052. --verbose-version Display detailed version of xmonad
  1053. Default keyboard bindings
  1054. mod-shift-return Launch terminal
  1055. mod-p Launch dmenu
  1056. mod-shift-p Launch gmrun
  1057. mod-shift-c Close the focused window
  1058. mod-space Rotate through the available layout algorithms
  1059. mod-shift-space Reset the layouts on the current workspace to default
  1060. mod-n Resize viewed windows to the correct size
  1061. mod-tab Move focus to the next window
  1062. mod-shift-tab Move focus to the previous window
  1063. mod-j Move focus to the next window
  1064. mod-k Move focus to the previous window
  1065. mod-m Move focus to the master window
  1066. mod-return Swap the focused window and the master window
  1067. mod-shift-j Swap the focused window with the next window
  1068. mod-shift-k Swap the focused window with the previous window
  1069. mod-h Shrink the master area
  1070. mod-l Expand the master area
  1071. mod-t Push window back into tiling
  1072. mod-comma Increment the number of windows in the master area
  1073. mod-period Deincrement the number of windows in the master area
  1074. mod-shift-q Quit xmonad
  1075. mod-q Restart xmonad
  1076. mod-shift-slash Run xmessage with a summary of the default keybindings
  1077. mod-[1..9] Switch to workspace N
  1078. mod-shift-[1..9] Move client to workspace N
  1079. mod-{w,e,r} Switch to physical/Xinerama screens 1, 2, or 3
  1080. mod-shift-{w,e,r} Move client to screen 1, 2, or 3
  1081. mod-button1 Set the window to floating mode and move by dragging
  1082. mod-button2 Raise the window to the top of the stack
  1083. mod-button3 Set the window to floating mode and resize by dragging
  1084. Examples
  1085. To use xmonad as your window manager add to your ~/.xinitrc file:
  1086. exec xmonad
  1087. Customization
  1088. xmonad is customized in ~/.xmonad/xmonad.hs, and the restarting with mod-q.
  1089. You can find many extensions to the core feature set in the xmonad-conrtib
  1090. package, available throught your package manager or from xmonad.org
  1091. Ref: https://xmonad.org/manpage.html#customization
  1092. # System Admin Skills
  1093. 1. Manage file systems
  1094. The single most important file related to file systems is /etc/fstab, which
  1095. holds their mount points, their types and various other permissions about
  1096. them - it is the job of the system administrator to alter and maintain the
  1097. /etc/fstab file in order to contain the correct information.
  1098. https://askubuntu.com/questions/420320/what-permissions-would-change-if-i-
  1099. change-umask-to-027-from-022
  1100. failed login attempts are logged in /var/log/faillog
  1101. https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-
  1102. ubuntu-quickstart
  1103. The magic of SysReq
  1104. Linux is usually stable enough to survive misbehaving software, but it is
  1105. possible for a program to lock up the whole computer. Before you reach for
  1106. the Power or Reset button and risk corrupting your file systems, there is a
  1107. better way to get out of it. You can send commands directly to the kernel by
  1108. holding down the Alt and SysReq (aka PrtScr) keys and pressing certain letter
  1109. keys. As the kernel listens for those directly, they work even if X is
  1110. completely locked and accepting no input.
  1111. The keys normally used to get out of a lockup are R, to reset the keyboard -
  1112. this occasionally fixes the problem on its own. Next, press E to send a TERM
  1113. signal to all processes, asking them to shut down cleanly, writing any data
  1114. to disk and closing any open files. Next in line is I, which sends a KILL
  1115. signal to all remaining processes, forcing them to shut down. Pressing S tells
  1116. the kernel to sync, flushing all buffers to disk so that remaining open files
  1117. can be closed cleanly. Press U to unmount all file systems and remount them
  1118. read-only, to avoid further data corruption. Finally, reboots the system.
  1119. So, that is: hold down Alt and SysReq and press R-E-I-S-U-B in turn, preferably
  1120. leaving a coubple of seconds between each. There are several, aminly silly,
  1121. mnemonics to help remember that sequence, the most appropriate being Reboot
  1122. Even if System Utterly Broken, but the easiet way to remember the sequence is
  1123. that it is BUSIER backwards. This is not something you should need very often,
  1124. but it is well worth remembering when you do.
  1125. ## cli-magic
  1126. w3m http://en.wikipedia.org/wiki/May_06
  1127. ## Documentation
  1128. Debian:
  1129. www.debian.org/doc
  1130. http://debian-handbook.info
  1131. Ubuntu:
  1132. https://help.ubuntu.com
  1133. https://help.ubuntu.com/community
  1134. www.askubuntu.com
  1135. Linux Mint:
  1136. www.linuxmint.com/documentation.php
  1137. OpenSuse:
  1138. http://doc.opensuse.org
  1139. Fedora:
  1140. http://docs.fedoraproject.org
  1141. CentOS:
  1142. www.centos.org/doc
  1143. RedHat:
  1144. http://tinyurl.com/rheldocs
  1145. Arch:
  1146. https://wiki.archlinux.org
  1147. ## ImageMagick
  1148. # Converts from JPEG format into PNG, original intact
  1149. convert image.jpg image.png
  1150. # can list the supported formats
  1151. convert -list format
  1152. # displays information about an image in a one-line summary. Add the -verbose
  1153. option to get a very detailed information report.
  1154. identify my_image.png
  1155. # This gives you a PNG image that is a maximum of 600 pixels wide and 400
  1156. pixels high. It preserves the aspect ratio and won't stretch, compress or
  1157. otherwise distort the image.
  1158. convert image.jpg -resize 600*400 image.png
  1159. # list color names
  1160. convert -list color
  1161. # for viewing image sequences(slideshows)
  1162. animate -delay 100 *.png
  1163. ## sxiv
  1164. sxiv -f -S 10 * # f - fullscreen, S - slideshow, 10 - 10 seconds, * - files
  1165. Enter # to view all images
  1166. ## Colors
  1167. #15242F terminal
  1168. #063A76 xmobar
  1169. ## ispell
  1170. ispell filename.txt # to run a spelling check
  1171. ispell highlights the first word it doesn't recognize. If the word is
  1172. misspelled, ispell usually offers one or more alternatives. Press R and
  1173. then the number beside the correct choice. In the screen capture above.
  1174. I'd press R and 0 to fix the error.
  1175. If, on the other hand, the word is correctly spelled, press A to move to the
  1176. next misspelled word. ispell saves your changes, creates a backup of the file
  1177. you just checked (with the extension .bak), and shuts down.
  1178. You need to tell it a file's format. When starting ispell, add -t for a Tex or
  1179. LaTex file, -H for an HTML file, or -n for a groff or troff file. For example,
  1180. if you enter
  1181. ispell -t myReport.tex, ispell ignores all markup.
  1182. If you don't want the backup file that ispell creates after checking a file,
  1183. add -x to the command line - for example, ispell -x myFile.txt
  1184. You can add a word to a personal word list by pressing I. This saves the word
  1185. to a file called .ispell_default in the root of your /home directory.
  1186. ## system-built
  1187. Taskbar: xmobar
  1188. http://projects.haskell.org/xmobar/
  1189. System tray: stalonetray
  1190. http://stalonetray.sourceforge.net/
  1191. Application launcher: dmenu
  1192. https://tools.suckless.org/dmenu/
  1193. Wallpaper setter: feh
  1194. https://feh/finalrewind.org/
  1195. Time management: calcurse
  1196. http://calcurse.org/
  1197. Image viewer: sxiv
  1198. https://github.com/muennich/sxiv
  1199. ## Man-pages
  1200. Using Git, you can obtain the very latest version of man-pages using the
  1201. following command:
  1202. $ git clone http://git.kernel.org/pub/scm/docs/man-pages/man-pages
  1203. You can see what's recently been pushed to kernel.org via CGit:
  1204. http://git.kernel.org/?p=docs/man-pages/man-pages.git
  1205. ## script - Recording the shell activities
  1206. $ script # Script started, file is typescript
  1207. Do whatever shell commands under script.
  1208. Press Ctrl-D to exit script.
  1209. $ vi typescript
  1210. ## popularity-contest
  1211. $ popularity-contest > /var/log/popularity-contest
  1212. $ popcon-largest-unused
  1213. ## apt-mark
  1214. To remove package from list of packages considered for removal, mark that
  1215. package as installed manually. You can do it using apt-mark:
  1216. $ apt-mark manual <package_name>
  1217. ## finger - displays information about the system users
  1218. $ finger # user information lookup program
  1219. ## clean and lean machine
  1220. fslint # a utility to find and clean various forms of lint on a filesystem,
  1221. especially duplicate files and broken symlinks.
  1222. debfoster # creates dependency files to enable you to keep track of what you
  1223. have installed.
  1224. localepurge # will remove all locale files from your system that you have
  1225. no need for
  1226. ## Pandoc
  1227. pandoc # pandoc is invoked without specifying any input files, it operates as
  1228. a filter, taking input from the terminal and sending its output back
  1229. to the terminal
  1230. By default, input is interpreted as pandoc markdown, and output is HTML.
  1231. # converting from HTML to markdown (hit Ctrl-D)
  1232. pandoc -f html -t markdown
  1233. # converting from markdown to LaTeX
  1234. pandoc -f markdown -t latex
  1235. # convert markdown file to HTML
  1236. pandoc test1.md -f markdown -t html -s -o test1.html
  1237. # convert markdown file to LaTeX
  1238. pandoc test1.md -f markdown -t latex -s -o test1.tex
  1239. To create a PDF, you'll need to have LaTeX installed.
  1240. pandoc test1.md -s -o test1.pdf
  1241. pandoc --help
  1242. ## update-alternatives command
  1243. $ ls -l $(type -p vi)
  1244. $ sudo update-alternatives --display vi
  1245. $ sudo update-alternatives --config vi
  1246. The Debian alternatives system keeps its selection as symlinks in
  1247. "/etc/alternatives/". The selection process uses corresponding file
  1248. in "/var/lib/dpkg/alternatives/".
  1249. ## font
  1250. # for core X11 font path
  1251. xset q
  1252. # for fontconfig font default
  1253. fc-match
  1254. # displays sorted list of best matching fonts, but do not do any pruning
  1255. fc-match -a
  1256. # displays sorted list of best matching fonts
  1257. fc-match -s
  1258. # for available fontconfig fonts
  1259. fc-list
  1260. ## watch - repeating a command with a constant interval
  1261. $ watch # executes a program repeatedly with a constant interval
  1262. $ watch w # this displays who is logged on to the system update every 2 seconds
  1263. ## scheduling tasks
  1264. scheduling tasks once
  1265. $ echo 'command -args' | at 3:40 monday
  1266. scheduling tasks regularly
  1267. $ cron(8)
  1268. # splitting a large file into small files
  1269. When a data is too big to backup as a single file, you cna backup its content
  1270. after splitting it into, e.g. 2000MiB chunks and merge those chunks back into
  1271. the original file late.
  1272. $ split -b 2000m large_file
  1273. $ cat x* > large_file
  1274. Please make sure you do not have any files starting with"x" to avoid name
  1275. crashes.
  1276. ## invisible disk space consumption
  1277. All deleted but open files consume disk space although they are not visible
  1278. from normal du. They can be listed with their size by the following.
  1279. # lsof -s -X / | grep deleted
  1280. $ lsof -i # to list all open network connections
  1281. ## pretty print a manual page
  1282. You can print a manual page in PostScript nicely by one of the following
  1283. commands.
  1284. $ man -Tps some_manpage | lpr
  1285. $ man -Tps some_manpage | mpage -2 | lpr # the second example prints 2 pages
  1286. on 1 sheet
  1287. ## merge two ps and pdf files
  1288. You can merge two postscript and portable document format files using gs of
  1289. ghostscript.
  1290. gs -q -dNOPAUSE -dBATCH -sDEVICE=pswrite -sOutputFile=bla.ps -f f1.ps f2.ps
  1291. gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=bla.pdf -f f1.pdf f2.pdf
  1292. https://www.ibm.com/developerworks/library/l-lpic1-map/index.html
  1293. ## parted - a partition manipulation program
  1294. parted --list # lists partition layout on all block devices
  1295. parted --help # displays a help message
  1296. parted --machine # displays machine parseable output
  1297. ## lpinfo - show available devices or drivers
  1298. lpinfo -v # list all devices
  1299. lpinfo -m # list all drivers
  1300. lpinfo --make-and-model "HP LaserJet" -m # list drivers matching "HP LaserJet"
  1301. ## Shell Scripting Tricks
  1302. # To see how much disk space is left
  1303. df
  1304. df -h # for a human readable format in megs & gigs
  1305. # To see where all my big files are
  1306. cd /somewhere
  1307. du -sk * | sort -nr
  1308. Repeat as necessary
  1309. # To see big directories instead of files
  1310. du -x /somewhere | sort -nr | head -10
  1311. This shows the 10 largest directories under /somewhere
  1312. Another way:
  1313. find /somewhere -size +2000k -ls
  1314. This shows all files over 2000 kilobytes under /somewhere
  1315. If you want to keep your .debs, you can filter them out of the list:
  1316. find / -size +2000k ! -name "*.deb" -ls
  1317. This shows all files on your entire system over 2000 kilobytes that
  1318. are not debian pkg.
  1319. # To rename them all with underscores instead of spaces
  1320. rename 's/ /_/g' *.mp3
  1321. This rename command is not a general Unix command but it's included with Perl
  1322. which is of course installed by default in Debian.
  1323. # To do that recursively
  1324. That's a bit tricky. You can get a list of files to pass to rename using find,
  1325. but if some of the directories are being renamed as well, that's not something
  1326. rename can keep track of. You have to use -depth with find to make sure any
  1327. files are renamed before the directories they're in.
  1328. cd /somewhere
  1329. find . -depth -name '* *' -type f -print0 | xargs -r0 rename 's/ /_/g'
  1330. # Systemd
  1331. systemd-analyze
  1332. systemd-analyze blame (results pipe to less by default, can use --no-pager)
  1333. systemd-analyze plot > /tmp/boot_plot.svg
  1334. # systemctl (not to be confused with sysctl) is used to manage units
  1335. systemctl start sshd.service # starting a unit
  1336. systemctl stop sshd.service # stopping a unit
  1337. systemctl restart sshd.service # restarting a unit
  1338. systemctl enable sshd.service # enable a unit to start at boot
  1339. systemctl disable sshd.service # disabling service so it does not run at boot
  1340. systemctl cat sshd.service # displaying the contents of a unit file
  1341. systemctl status sshd.service # to get information about a unit
  1342. systemctl suspend # sleep (suspend to RAM)
  1343. systemctl hibernate # hibernate (suspend to Disk)
  1344. # /sbin/shutdown task
  1345. systemctl reboot # reboot
  1346. systemctl halt # halt system (without powering off)
  1347. systemctl poweroff # power off system
  1348. systemctl --type service --state active # list services
  1349. systemctl list-unit-files --type=service # list all services
  1350. systemctl list-dependencies multi-user.target --no-pager # list all services by target
  1351. systemctl list-units --type target # view list of currently loaded targets
  1352. systemctl # lots of options...
  1353. systemctl- # lots of new commands...
  1354. # journalctl is used to interact with the journal
  1355. journalctl /path/to/executable # show all messages by a specific executable
  1356. journalctl _PID=456 # show all messages by a specific PID (ex. 456)
  1357. journalctl _SYSTEMD_INIT=sshd.service # show all messages by a specific unit
  1358. journalctl # show all messages in journal (view basic logs)
  1359. journalctl -n 10 # view most recent logs (-f to follow)
  1360. journalctl -p err # filter by priority
  1361. journalctl -p err --since "2015-2-17 18:00:00" --until "2015-2-17 18:10:00"
  1362. # filter by time and priority
  1363. # similar to the tail command, the -f flag can be used to follow the journal,
  1364. while the -n flag can be used to limit results to a number of most recent
  1365. messages, run man journalctl for the full list of options
  1366. # mpv
  1367. mpv [options] filename
  1368. mpv --shuffle /folder-path/*
  1369. mpv --playlist=filename.pls
  1370. # to activate the gapless audio optiona
  1371. mpv --gapless-audio --playlist=filename.pls
  1372. mpv --help
  1373. mpv --list-options
  1374. mpv link_to_youtube_vid --no-video # audio only format
  1375. # route
  1376. route -n
  1377. # nslookup - query Internet name servers interactively
  1378. nslookup <url>
  1379. nslookup -query=mx <url>
  1380. nslookup -type=ns <url> # query name server
  1381. nslookup -type=any <url> # query DNS record
  1382. nslookup -type-soa <url> # query start of authority
  1383. nslookup -port 56 <url? # query port number
  1384. # dig - a tool for querying DNS nameservers for information about host address,
  1385. mail exchanges, nameservers, and related information
  1386. dig <url>
  1387. dig <url> +nocomments # turn off comment lines
  1388. dig <url> +noauthority # turn off authrity section
  1389. dig <url> +noadditional # turn off additional section
  1390. dig <url> +nostats # turn off stats section
  1391. dig <url> +noanswer # turn off answer section
  1392. dig <url> +noall # disable all section at once
  1393. # uptime - verify what happened actually when the server was unattended
  1394. # wall "mesg" - sends mesg to everybody logged with their mesg permission yes
  1395. # mesg [n|y] - contrl people who can use the "write" command
  1396. # write <user_name> - send text directly to the screen of another linux machine
  1397. # talk <username> - lets you talk to the logged in users
  1398. # w - combination of uptime and who commands
  1399. # mysqldump
  1400. mysqldump -u root -p -all-databases > /home/server/Desktop/backupfile.sql
  1401. # mkpasswd
  1402. mkpasswd -l 10
  1403. # imagemagick
  1404. convert source.jpg -colorspace Gray destination.jpg # true grayscale only
  1405. convert source.jpg -monochrome destination.jpg # true black and white
  1406. convert source.jpg -separate destination.jpg # separate into gray channels
  1407. identify <image> # list size of image
  1408. convert -crop +0+100 <input_image> <output_image> # crop the image from top
  1409. convert -crop +0-100 <input_image> <output_image> # crop the image from bottom
  1410. convert -crop -5+0 <input_image> <output_image> # crop the image from right
  1411. convert -crop +5+0 <input_image> <output_image> # crop the image from left
  1412. # Installing the same selection of packages several times
  1413. It can be useful to systematically install the same list of packages on several
  1414. computers. This can be done quite easily.
  1415. First, retrieve the list of packages installed on the computer which will
  1416. serve as the "model" to copy.
  1417. $ dpkg --get-selections > pkg-list
  1418. The pkg-list file then contains the list of installed packages. Next, transfer
  1419. the pkg-list file onto the computers you want to update and use the following
  1420. commands:
  1421. ## Update dpkg's database of known packages
  1422. # avail='mktemp'
  1423. # apt-cache dumpavail > "$avail"
  1424. # dpkg --merge-avail "$avail"
  1425. # rm -f "$avail"
  1426. ## Update dpkg's selections
  1427. # dpkg --set-selections < pkg-list
  1428. ## Ask apt-get to install the selected packages
  1429. # apt-get dselect-upgrade
  1430. The first commands records the list of available packages in the dpkg database,
  1431. then dpkg --set-selections restores the selection of packages that you wish to
  1432. install, and the apt-get invocation executes the required operations! aptitude
  1433. does not have this command.
  1434. [Sources: pg. 108 The Debian Administrator's Handbook]
  1435. # deborphan
  1436. deborphan -sz
  1437. sudo apt remove --purge $(deborphan)
  1438. $ count the number of sub-directories
  1439. find ./* -type d | wc -l
  1440. Note: Remember to use ./* if you don't want to include the current directory
  1441. itself in the total
  1442. Note: Always read offical installation guide for Debian/Ubuntu
  1443. # find
  1444. find . -print # print all files and directories in current directory
  1445. find . -type f -ls # print all files with details
  1446. find . -type f # print only files in current directory, no directory
  1447. find . -type d # print only directories in current directory, no files
  1448. find ~ -name bu -type d # print only 'bu' directories in ~
  1449. find . -name my_file.txt # print only my_file.txt in .
  1450. find ~ -name '*.txt' # search for '*.txt' in ~
  1451. find . -iname '*.jpg' # find files by case-insensitive extension (ex: .jpg)
  1452. find . -type f -perm 777 # to find files by octal permission
  1453. find . -size +10M -print # find all files larger than 10M
  1454. find . -type f -mmin -60 # find all files that were changed within last 60 min.
  1455. find . -type f -exec mv {} {}.py # add all files with ".py" at the end
  1456. find . -type f -name "*cmd*" # find files whose names have the string "cmd"
  1457. # find files whose names have the string
  1458. find . -type f -name "*cmd*" or -name "*line*"
  1459. # find files whose names have the string
  1460. find . -type f -name "*cmd*" and -name "*line*"
  1461. # find all directories in the current directory and their disk usage
  1462. find * -prune -type d -exec du -skh {} \;
  1463. # wn - command line interface to WordNet lexical database
  1464. wn perusing -over # to find definition of word perusing
  1465. # Text
  1466. less -M # for file name, the current and total lines
  1467. iostat
  1468. # history
  1469. history -c # to clear shell history
  1470. ctrl P / ctrl N # backward & forward of commands in history in the shell prompt
  1471. # wn - command line interface to WordNet lexical database
  1472. wn <word> -over # read wn man page
  1473. # nmap - Network exploration tool and security/port scanner
  1474. nmap -h # Nmap help
  1475. nmap scanme.nmap.org # default scan 1000 ports
  1476. nmap -p 22 scanme.nmap.org # scan port 22 alone
  1477. nmap -A scanme.nmap.org # OS information
  1478. nmap -F scanme.nmap.org # most important targeted ports
  1479. nmap -sV scanme.nmap.org # short information
  1480. nmap --open scanme.nmap.org # open ports alone
  1481. nmap -A -T4 slackware.com
  1482. ifconfig
  1483. ipcalc 192.168.42.136
  1484. nmap -F 192.168.42.8/24
  1485. sudo arp-scan -l
  1486. https://nmap.org/
  1487. https://www.nirsoft.net/countryip/ # Major IP Addresses Blocks by Country
  1488. who is <ip_address> # in web browser
  1489. geoiplookup.net/ip-addresses/<ip_address>
  1490. # checking package integrity
  1491. The md5sum command is used to compute a 128-bit fingerprint that is strongly
  1492. dependant upon the contents of the file to which it is applied. It can be used
  1493. to compare against a previously-generated sum to determine whether the file
  1494. has changed. It is commonly used to ensure the integrity of updated packages
  1495. distributed by a vendor:
  1496. sudo md5sum <package-name>
  1497. # ufw
  1498. sudo ufw app list # available applications
  1499. sudo ufw allow OpenSSH # to allow SSH connections
  1500. sudo ufw enable # enable the firewall
  1501. sudo ufw status # status of the firewall
  1502. sudo ufw status verbose
  1503. Block an IP Address
  1504. To block all network connections that originate from a specific IP address,
  1505. 15.15.15.51
  1506. $ sudo ufw deny from 15.15.15.51
  1507. [source IP address - 15.15.15.51, subnet IP address - 15.15.15.0/24]
  1508. Note: the source IP address can be specified in any firewall rule
  1509. Block connections to a Network interface:
  1510. To block connections from a specific IP address, eg. 15.15.15.51, to a specific
  1511. network interface, eg. eth0, use this command.
  1512. $ sudo ufw deny in on eth0 from 15.15.15.51
  1513. This is the same as the previous example, with the addition of in on eth0.
  1514. The netwoek interface can be specified in any firewall rule and is a great
  1515. way to limit the rule to a particular network.
  1516. Reference:
  1517. https://www.digitalocean.com/community/tutorials/ufw-essentials-common-
  1518. firewall-rules-and-commands
  1519. https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-
  1520. with-ufw-on-ubuntu-16-04
  1521. # apt-file
  1522. apt-file is a command line tool for searching packages in Debian repositories
  1523. sudo apt install apt-file # to install apt-file
  1524. sudo apt-file update # to update apt-file database
  1525. apt-file search <package_name> # to query the database for <package_name>
  1526. apt-file search path/to/<package_name>
  1527. apt-file list <package_name> # to list the content of an uninstalled package
  1528. sudo apt-file purge # to delete the cache files
  1529. # user
  1530. # add user Mark [-m tells Linux to create home directory]
  1531. sudo useradd -m mark
  1532. # to create password for Mark
  1533. sudo passwd mark
  1534. # to remove a user by name mark
  1535. sudo userdel mark
  1536. # set date on which the account will expire
  1537. sudo usermod -e 2017-12-31 mark
  1538. # to change Mark's login name to Henry
  1539. sudo usermod -l henry mark
  1540. # to temporarily lock Mark out of his account
  1541. sudo usermod -L mark
  1542. # using -U will unlock and -G will add/remove membership group
  1543. sudo usermod -G sudo mark
  1544. # to force users to change password (no < 5 but no > 30 days)
  1545. sudo chage -m 5 -M 30 mark
  1546. # to send Mark a warning seven days before his deadline
  1547. sudo chage -W 7 mark
  1548. # to list Mark's current settings
  1549. sudo chage --list mark
  1550. Note: Referance Practical_LPIC-1.pdf (page:102)
  1551. # user and permissions
  1552. ## create a user called ashley
  1553. useradd --create-home ashley
  1554. ## create a user in groups "users" and "dev"
  1555. useradd --create-home --groups users dev ashley
  1556. ## create a user with the UID 1337
  1557. useradd --create-home --uid 1337 ashley
  1558. ## create or change a user password
  1559. passwd ashley
  1560. <enter password>
  1561. ## add user to a group "coder"
  1562. usermod --append --groups coder ashley
  1563. ## remove a user from a group "coder"
  1564. gpasswd --delete ashley coder
  1565. ## delete a user from the system
  1566. userdel ashley
  1567. ## delete a user and all user data from the system
  1568. userdel --remove ashley
  1569. ## show which users are currently logged in
  1570. w
  1571. ## show login history
  1572. last
  1573. ## set default permission of files to 644
  1574. echo "umask 022" >> /etc/profile
  1575. ## set default permission of files to 664
  1576. echo "umask 002" >> /etc/profile
  1577. ## change ownership of a file "example.txt" to user "ashley"
  1578. chown ashley:users example.txt
  1579. ## give read permission to user, group, and others
  1580. chmod ugo+r example.txt
  1581. ## give write permissions to user and group
  1582. chmod ug+w example.txt
  1583. ## remove write permission to a file for group members
  1584. chmod g-w example.txt
  1585. ## make a file executable
  1586. chmod +x example.txt
  1587. ## log in as a different user
  1588. su - ashley
  1589. ## run a command "ls" as a different user
  1590. su - ashley --command ls
  1591. # vagrant
  1592. # cfdisk
  1593. # Basic text analysis with command line tools in Linux
  1594. Book from Internet Archive for text analysis.
  1595. Jane Andrews, The Stories Mother Nature Told Her Children (1888, 1894)
  1596. (Project Gutenberg collection)
  1597. wget http://archive.org/download/thestoriesmother05792gut/stmtn10.txt
  1598. file stmtn10.txt
  1599. stmtn10.txt: C source, ASCII text, with CRLF line terminators
  1600. Note: The output of the file command confirms that this is an ASCII text,
  1601. guesses that it is some code in the C programming language (which is incorrect)
  1602. and tells us that the ends of the lines in the file are coded with both a
  1603. carriage return and a line feed.
  1604. This is standard for window computers. Linux expect the ends of lines in an
  1605. ASCII text file to be coded only with a line feed. If we want to move text
  1606. files between operating systems, this is one thing we have to pay attention to.
  1607. The head & tail commands show us the first few and last few lines of the file.
  1608. head stmtn10.txt
  1609. tail stmtn10.txt
  1610. Before modifying files, it is usually a good idea to make a copy of the
  1611. original. We can do this with the cp command.
  1612. cp stmtn10.txt stmtn10-backup.txt
  1613. less -N stmtn10.txt # option -N to include line numbers at the beginning
  1614. of each line
  1615. # command to delete all of the material between lines 2206 and 2525
  1616. sed '2206,2525d' stmtn10.txt > stmtn10-nofooter.txt # sed - Linux stream editor
  1617. sed '1,40d' stmtn10-nofooter.txt > stmtn10-trimmed.txt
  1618. wc -l stmtn10-trimmed.txt # number of lines
  1619. wc -m stmtn10-trimmed.txt # number of characters
  1620. grep # pattern-matching command
  1621. # command below shows lines which contain the word giant,
  1622. this pattern is case sensitive
  1623. grep -n "giant" stmtn10-trimmed.txt # option -n to include line numbers
  1624. grep -E -n "(G|g)iant" stmtn10-trimmed.txt
  1625. grep -i, --ignore-case
  1626. grep -o
  1627. grep -v
  1628. grep -A NUM, --after-context=NUM
  1629. grep -B NUM, --before-context=NUM
  1630. grep -C NUM, -NUM, --context=NUM
  1631. # When we are analyzing the words in a text, it is usually convenient to
  1632. create a standardized version that eliminates whitespace and punctuation
  1633. and converts all characters to lowercase. We use the tr command to translate
  1634. and delete characters of our trimmed text, to create a standardized version.
  1635. Note that in this case the tr command requires that we use the redirection
  1636. operators to specify both the input file (<) and the output file (>).
  1637. # delete all punctuation
  1638. tr -d [:punct:] < stmtn10-trimmed.txt > stmtn10-nopunct.txt
  1639. # upper to lower
  1640. tr [:upper:] [:lower:] < stmtn10-nopunct.txt > stmtn10-lowercase.txt
  1641. # Counting word frequencies
  1642. # translate ' ' to '\n'
  1643. tr ' ' '\n' < stmtn10-lowercaself.txt > stmtn10-oneword.txt
  1644. # to sort that file so the words are in alphabetical order,
  1645. and so that if a given word appears a number of times, these
  1646. are listed one after another.
  1647. sort stmtn10-newword.txt > stmtn10-onewordsort.txt
  1648. # uniq command with the -c option to count the number of repetitions
  1649. of each line
  1650. uniq -c stmtn10-onewordsort.txt > stmtn10-wordfreq.txt
  1651. # all commands in one line
  1652. tr ' ' '\n' < stmtn10-lowercaself.txt | sort | uniq -c > stmtn10-wordfreq2.txt
  1653. # search for a particular term with the forward slash (/giant, for example)
  1654. Ref: https://williamjturkel.net/2013/06/15/basic-text-analysis-with-command-
  1655. line-tools-in-linux/
  1656. # Virtual Machine
  1657. virtinst - Program to create and clone virtual machines
  1658. virt-install
  1659. virt-manager
  1660. # Running Linux as a guest VM
  1661. Reference: Linux_Kernel_Programming.pdf (page no. 14)
  1662. # pdftotext
  1663. pdftotext -layout report.pdf report.txt
  1664. # calcurse
  1665. calcurse -t # List all todo items
  1666. calcurse -a # Print the appointments and events for the current day and exit
  1667. calcurse -r7 # Print appointments and events for the next seven days
  1668. # Reviewing what you did today
  1669. # To list all the files in your home directory tree, excluding direcotries,
  1670. that were accessed today: $ find ` -daystart -atime -1 \! -type d
  1671. # To list all the files in your home directory tree, excluding directories,
  1672. that were modified today: $ find ~ -daystart -mtime -1 \! -type d
  1673. # To list all the files in your home directory tree, excluding diretories,
  1674. that were accessed between now and two days ago:
  1675. $ find ~ -daystart -atime -2 \! -type d
  1676. # To list all the files in your home directory tree, excluding directories,
  1677. that were modified exactly two days ago: $ find ~ -daystart -mtime 2 \! -type d
  1678. # To find out what you did on September 11, 2001, type:
  1679. $ touch -d "Sep 11 2001" /tmp/911
  1680. $ touch -d "Sep 12 2001" /tmp/912
  1681. $ find ~ -daystart -newer /tmp/911 \! -daystart -newer /tmp/912
  1682. # expand and unexpand
  1683. expand -t 10 filename # convert every tab to ten spaces
  1684. unexpand -t 3 filename # convert every three spaces to tabs
  1685. # format text
  1686. fmt -w 60 filename # start a new line after 60 characters
  1687. fmt -t filename # indent all but the first line of a paragraph
  1688. # docker
  1689. Method 1: Managing services in linux with systemd
  1690. systemctl list-unit-files --type service -all # list all services
  1691. sudo systemctl | grep running # list running services
  1692. systemctl start docker.service # start a service
  1693. systemctl start docker.socket
  1694. systemctl stop docker.service # stop a service
  1695. systemctl stop docker.socket
  1696. systemctl restart docker.service # restart a service
  1697. systemctl restart docker.socket
  1698. systemctl status docker.service # check the status of a service
  1699. systemctl status docker.socket
  1700. Method 2: Managing services in linux with init
  1701. service --status-all # list all services ([-] are disabled and [+] are enabled)
  1702. service <service-name> start # start a service
  1703. service <service-name> stop # stop a service
  1704. service <service-name> restart # restart a service
  1705. service <service-name> status # check the status of a service
  1706. # Format USB Drive
  1707. Step 1: Insert USB and Identify Volume
  1708. Insert a USB drive into your system and identify your USB drive correctly. This
  1709. is the step you need to take care, because you may format the wrong disk if not
  1710. correctly identify your disk.
  1711. $ df -h
  1712. Step 2: Format USB Drive in Linux
  1713. Whenever we attach a USB drive, it automatically mounted to the system. We can
  1714. not format any disk on Linux systems which are already mounted. So first
  1715. un-mount /dev/sdc1 USB drive on your system.
  1716. $ sudo umount /dev/sdc1
  1717. Step 3: Format with vFat file system $ sudo mkfs.vfat /dev/sdc1
  1718. Format with NTFS file system $ sudo mkfs.ntfs /dev/sdc1
  1719. Format with EXT4 file system $ sudo mkfs.ext4 /dev/sdc1
  1720. # Translate html to text
  1721. cat index.html | w3m -dump -T text/html > index.txt
  1722. # Permissions and their likely uses (chmod 700 /home/user/file)
  1723. Permission Octal_Code Meaning
  1724. rwxrwxrwx 777 Read, write, and execute permissions for all users
  1725. rwxr-xr-x 755 Read and execute permission for all users. The file
  1726. owner also has write permission.
  1727. rwxr-x--- 750 Read and execute permission for the owner and group.
  1728. The file's owner also has write permission. Users
  1729. who are not the file's owner or members of the group
  1730. have no access to the file.
  1731. rwx------ 700 Read, write, and execute permissions for the file's
  1732. owner only; all others have no access.
  1733. rw-rw-rw- 666 Read and write permissions for all users. No execute
  1734. permissions to anybody.
  1735. rw-rw-r-- 664 Read and write permissions to the owner and group.
  1736. Read-only permission to all others.
  1737. rw-rw---- 660 Read and write permissions to the woner and group.
  1738. No world permissions.
  1739. rw-r--r-- 644 Read and write permissions to the owner. Read-only
  1740. permission to all others.
  1741. rw-r----- 640 Read and write permissions to the owner, and read-
  1742. only permission to the group. No permission to other
  1743. rw------- 600 Read and write permissions to the owner. No permiss-
  1744. ion to anybody else.
  1745. r-------- 400 Read permission to the owner. No permission to any-
  1746. body else.
  1747. # netstat
  1748. netstat -p > net_connections.txt # redirect stdoutput to file
  1749. netstat -p 2> error_messages.txt # redirect stderror to file
  1750. netstat -p &> net_connections.txt # redirect stdoutput and stderror to file
  1751. # Common Environment variables and their meanings
  1752. Variable_Name Explanation
  1753. $USER This is your current username. It's a variable that's
  1754. maintained by the system.
  1755. $SHELL This variable holds the path to the current command shell.
  1756. $PWD This is the present working directory. This environment
  1757. variable is maintained by the system. Programs may use it to
  1758. search for files when you don't provide a complete pathname.
  1759. $HOSTNAME This is the current TCP/IP hostname of the computer.
  1760. $PATH This is an unusually important environment variable. It sets
  1761. the path for a session; the path is a coon-delimited list of
  1762. directories in which Linux searches for executable programs
  1763. when you type a program name. For instance, if PATH is
  1764. /bin:/usr/bin and you type ls, Linux looks for an executable
  1765. program called ls in /bin and then in /usr/bin If the command
  1766. you type isn't on the path, Linux responds with a command not
  1767. found error. The $PATH variable is typically built up in
  1768. several configuration files, such as /etc/profile and the
  1769. .bashrc file in the user's home directory.
  1770. $HOME This variable points to your home directory. Some programs
  1771. use it to help them look for configuration files or as a
  1772. default location in which to store files.
  1773. $LD_LIBRARY_PATH A few programs use this environment variable to indicate
  1774. directories in which library files may be found. It wroks
  1775. much like PATH.
  1776. $PS1 This is the default prompt in bash. It generally includes
  1777. variables of its own, such as \u (for the username),
  1778. \h (for the hostname), and \# (for the current working
  1779. directory). This value is frequently set in /etc/profile,
  1780. but it is often overridden by users.
  1781. $TERM This variable is the name of the current terminal type.
  1782. $DISPLAY This variable identifies the display used by X. It's usually
  1783. :0.0, which means the first (numbered from 0) display on the
  1784. current computer. When you use X in a networked environment,
  1785. though, this value mey be preceded by the name of the
  1786. computer at which you're sitting, as in machine4.example.com:
  1787. 0.0. This value is set automatically when you log in, but you
  1788. may change it if necessary. You can run multiple X sessions
  1789. on one computer, in which case each one gets a different
  1790. DISPLAY number - for instance, :0.0 for the first session
  1791. and :1.0 for the second.
  1792. $EDITOR Some programs launch the program pointed to by this
  1793. environment variable when they need to call a text editor
  1794. for you to use.
  1795. # Verify that the hash matches the downloaded image:
  1796. You need to verify that the hash matches the downloaded image, and then verify
  1797. that the hash was signed by an official Debian key - as explained in
  1798. (https://linuxconfig.org/how-to-verify-an-authenticity-of-downloaded-debian-
  1799. iso-images).
  1800. 1. Download your CD image, a SHA 512 hash, and the hash signature. (debian.org)
  1801. 2. Verify that the hash matches the image
  1802. $ sha512sum debian-8.3.0-i386-netinst.iso > my_hash.txt
  1803. $ diff -q my_hash.txt SHA512SUMS
  1804. 3. Verify the hash is properly signed. You'll probably have to do it twice:
  1805. once to get the key ID, and again after you have downloaded the public key.
  1806. $ gpg --verify SHA512SUMS.sign SHA512SUMS
  1807. gpg: Signature made Mon 25 Jan 2016 05:00:46 AEDT using RSA key ID 6294BE9B
  1808. $ gpg --keyserver keyring.debian.org --recv 6294B#9B
  1809. $ gpg --verify SHA512SUMS.sign SHA512SUMS
  1810. 4. Verify that the key fingerprint (the last printed line) is legitimate.
  1811. Ideally, you should do this via a web of trust
  1812. (https://www.gnupg.org/gph/en/manual/x547.html).
  1813. However you can check the key fingerprint against the keys listed on Debian's
  1814. website (https://www.debian.org/CD/verify).
  1815. Ref: https://unix.stackexchange.com/questions/138603/how-to-verify-debian-iso-
  1816. integrity
  1817. # Check the Hard Disk Serial Number in Linux
  1818. # to know the device names of your disks
  1819. df -h
  1820. # displays the hard drive model and vendor but not serial number
  1821. hwinfo
  1822. # displays the list of hardware installed on your machine
  1823. lshw
  1824. # displays the serial number
  1825. lshw -class disk
  1826. # is a tool part of the smartmontools package (sudo apt install smartmontools)
  1827. smartctl
  1828. # displays the serial number
  1829. smartctl -i /dev/sda
  1830. # displays the serial number
  1831. hdparm -i /dev/sda
  1832. # Hex codes
  1833. Hex: #101718 RGBA(16,23,24,1)
  1834. HeX: #1f2a2e RGBA(31,42,46,1)
  1835. # awk
  1836. awk 'NR==100' filename.txt # print text in line number 100 from filename.txt
  1837. awk 'NR>=100 && NR<=110' filename.txt # print text between lines 100 and 110
  1838. # set default web browser
  1839. sudo update-alternatives --list x-www-browser
  1840. sudo update-alternatives --config x-www-browser
  1841. # xdg-open
  1842. xdg-open file.csv # opens file.csv in default application
  1843. # tee
  1844. echo "institute of mathematical sciences" | tee -a institute.txt
  1845. # display cursor size in debian
  1846. gsettings get org.gnome.desktop.interface cursor-size
  1847. gsettings set org.gnome.desktop.interface cursor-size 20
  1848. # show history of recently installed packages, their version number, and the
  1849. date/time they were installed:
  1850. grep "install" /var/log/dpkg.log
  1851. # show a list of recently upgraded packages, the date/time they were upgraded,
  1852. as well as the old and new package version:
  1853. grep "upgrade" /var/log/dpkg.log
  1854. # show a history of recently removed packages and the date/time they were
  1855. removed:
  1856. grep "remove" /var/log/dpkg.log
  1857. # /var/log/dpkg.log contains the package install, update and remove history
  1858. for the current month. For the previous month, read the /var/log/dpkg.log.1
  1859. log file.
  1860. grep "install" /var/log/dpkg.log.1
  1861. # want to go back even more in the dpkg history? Use zgrep instead of grep,
  1862. and read /var/log/dpkg.log.2.gz, /var/log/dpkg.log.3.gz, /var/log/dpkg.log.4.gz
  1863. and so on, which go back two, three and respectively four months:
  1864. zgrep "upgrade" /var/log/dpkg.log.2.gz
  1865. This is because by default, the dpkg log is set to rotate once a month, keeping
  1866. 12 old logs (so for 12 months), and compress rotated files by using gzip (.gz).
  1867. You can check the Debian Logrotate configuration for dpkg by using cat
  1868. /etc/logrotate.d/dpkg
  1869. # to check sudo access for a user
  1870. sudo -l
  1871. # to check init or systemd
  1872. ps --no-headers -o comm 1
  1873. # init service commands
  1874. sudo service ssh status/start/stop/restart/reload/condrestart
  1875. # public IP address
  1876. curl ifconfig.me
  1877. # private IP address
  1878. hostname -I
  1879. ip addr
  1880. ifconfig
  1881. # rename user in linux
  1882. usermod -l nname oname
  1883. # ssh with port number
  1884. ssh -p 22 user@hostname
  1885. # cat two files
  1886. cat -n {file1.txt,file2.txt}
  1887. cat -n file1.txt file2.txt
  1888. # make directory with mode
  1889. mkdir -m777 <directoryname>
  1890. # MySQL
  1891. sudo dpkg-reconfigure mysql-apt-config
  1892. apt-policy mysql-server
  1893. dpkg -l | grep -i 'mysql'
  1894. # List only sub-directories of the current directory
  1895. ls -d */
  1896. # qutebrowser
  1897. .venv/bin/python -m qutebrowser --temp-basedir
  1898. # change bash shell prompt
  1899. PS1="g62231tx:~$ "
  1900. # extract .7z file
  1901. sudo apt-get install p7zip p7zip-full p7zip-rar
  1902. man p7zip; man 7za
  1903. 7za e <filename>.7z
  1904. # reference the last argument of the previous command
  1905. ls Downloads/
  1906. cd $_
  1907. # work on files and directories
  1908. mkdir -v dir_{rpm,txt,zip,pdf}
  1909. # find command by example
  1910. find . -type f -name '*statistical*' | less -N
  1911. find . -iname '*statistical*' | less -N
  1912. # xdg-open
  1913. xdg-open <filename>
  1914. # access last argument of the previous command
  1915. mkdir Example
  1916. cd !$ (equivalent to 'cd Example')
  1917. # shellcheck
  1918. shellcheck file.sh
  1919. # change to previous directory and change to directory
  1920. cd ../Directory
  1921. # locate command
  1922. sudo updatedb # update database
  1923. locate -i 'searchtext'
  1924. # aspell
  1925. echo word | aspell -a
  1926. aspell check text.txt
  1927. # path of the command
  1928. type -P <command>
  1929. which <command>
  1930. # display one-line manual page descriptions
  1931. whatis <command>
  1932. # linux version
  1933. cat /etc/os-release
  1934. hostnamectl
  1935. lsb_release -a
  1936. uname -r
  1937. # merge images in command line
  1938. convert image1.png image2.png image3.png -append Sprite/verticalsprite.png
  1939. convert image1.png image2.png image3.png +append Sprite/horizontalsprite.png
  1940. convert image{1..12}.png -append Sprite/verticalsprite.png
  1941. convert image{1..12}.png +append Sprite/horizontalsprite.png
  1942. gm convert image1.png image2.png image3.png -append Sprite/verticalsprite.png
  1943. gm convert image1.png image2.png image3.png +append Sprite/horizontalsprite.png
  1944. # resize an image [Ref: https://imagemagick.org/]
  1945. magick mogrify -resize 50% image.jpg # reduce the size of image.jpg by 50%
  1946. magick mogrify -resize 256x256 image.jpg # resize image.jpg to a dimension of 256x256
  1947. magick mogrify -format jpg image.png # convert PNG format image.png to the JPEG format
  1948. convert input.png -resize 200x100 output.png # preserve the aspect ratio
  1949. convert input.png -resize 200x100! output.png # don't preserve the aspect ratio
  1950. convert input.png -resize 200 output.png # resize an image to a width of 200
  1951. convert input.png -resize x100 output.png # resize an image to a height of 100
  1952. # rotate an image
  1953. convert input.jpg -rotate 180 output.jpg
  1954. for image in *.jpg; do convert $image -rotate 90 $image; done
  1955. mogrify -rotate 90 image.jpg
  1956. # applying effects
  1957. convert input.png -charcoal 2 output.png # apply charcoal effect to an image (2=strength)
  1958. convert input.png -implode 1 output.png # apply implode effect to an image
  1959. # combining operations
  1960. convert input.png -resize 400x400 -rotate 180 -charcoal 4 -quality 95 output.png
  1961. # xset - user preference utility for X
  1962. xset q - information on the current settings
  1963. # package management
  1964. aptitude update # updating package database
  1965. aptitude upgrade --simulate # showing available updates
  1966. aptitude install pkg1 pkg2 # updating a particular package
  1967. apt-get install pkg1 pkg2 # installing packages
  1968. apt-get install --reinstall pkg1 pkg1 # reinstalling a particular package
  1969. apt-cache search <searchword> # searching the package database
  1970. apt-cache search --full --names-only <searchword> # long package information
  1971. apt-get remove package1 package2 # removing packages
  1972. apt-get remove --purge package1 package2 # remove along with all configuration files
  1973. apt-get install --download-only pkg1 pkg2 # only downloading packages
  1974. apt-get clean # cleaning up downloaded packages
  1975. apt-get autoclean # remove outdated packages
  1976. # 50 linux commands
  1977. Linux commands for navigating the file system:
  1978. pwd - print work directory
  1979. ls - list files
  1980. cd - change directory
  1981. mkdir - make directory
  1982. rmdir - remove empty directory
  1983. lsblk - list block devices
  1984. mount - mount SD card or USB in existing filesystem
  1985. df - information about the disk space on filesystem
  1986. Linux commands for manipulating the system:
  1987. uname - system information (name, version, ...)
  1988. ps - processes currently running
  1989. kill - stop processes that are struck due to resource constraints
  1990. service - invoke system-wide services (System V init)
  1991. batch - run system services in apre-defined schedule (automation shell scripts)
  1992. shutdown - shutdown the system
  1993. Linux commands for taking care of your files:
  1994. touch - creating a valid empty file (command for changing timestamps)
  1995. cat - concatenating multiple files
  1996. head - view the beginning of a file
  1997. tail - vies the ending of a file
  1998. cp - copy a file or directory
  1999. mv - move/rename a file or directory
  2000. comm - compare two files for common and distinct lines
  2001. less - viewing the contents of a file
  2002. ln - creating symbolic links to a file
  2003. cmp - compare two files and print the result tot the standard output stream
  2004. dd - copy and convert files from one type to another (creating bootable live USB sticks)
  2005. alias - replace a word by another string in files directly from the terminal
  2006. Funny Linux commands to explore:
  2007. cal - calendar in an ASCII text format
  2008. fortune - print poignant, inspirational, or silly phrases in terminal
  2009. history - history of terminal sessions
  2010. yes - ouput a string repeatedly until killed
  2011. banner - ASCII banners
  2012. rev - print text reversing each character
  2013. Linux commands for network administrators:
  2014. wget - download files from the web from the terminal
  2015. iptables - control the incoming and outgoing internet traffic on a host machine
  2016. traceroute - determine the route a network packet takes on its way form machine to another
  2017. curl - transferring files over a network (network related shell scripts)
  2018. Linux commands for search and regular expression:
  2019. find - search for files based on file permissions, ownership, modification date, size, ...
  2020. which - locate the path of a command
  2021. locate - location of a specific file by regular expression
  2022. grep - search for patterns
  2023. sed - manipulate a file or stream by replacing specific parts
  2024. Linux commands that deal with I/O and ownership:
  2025. clear - clear out existing terminal screen
  2026. echo - output a specific text to the terminal console
  2027. sort - sort out a file in an alphabetical or reverse manner
  2028. sudo - lets non-privileged users access
  2029. chmod - change/modify the access permissions of system files or directory
  2030. chown - change/modify the ownership of a file or directory
  2031. Linux command miscellaneous for use:
  2032. man - manual
  2033. tar - archiving files and extracting them
  2034. whatis - display one-line manual page descriptions
  2035. # column
  2036. dpkg -S $(which column)
  2037. dpkg -l | grep -i 'util-linux'
  2038. man column
  2039. column -t /etc/passwd
  2040. column -t -s ":" -n /etc/passwd
  2041. column -e -t -s "," file.txt
  2042. column -x file.txt
  2043. # rotate screen in linux with xrandr
  2044. xrandr -o left # orientation left
  2045. xrandr -o right # orientation right
  2046. xrandr -o normal # orientation normal
  2047. # sponge command to replace changes/manipulates in data file
  2048. column -t data.csv | sponge data.csv
  2049. # list installed deb packages by size
  2050. dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n
  2051. wajig large
  2052. dpigs
  2053. dpkg-query -W --showformat='$PInstalled-Size}\t${Package}\n' | sort -nr | less
  2054. glimpse
  2055. nethogs
  2056. # display the GPU info
  2057. sudo lshw -C display -short
  2058. lspci -v | less
  2059. # GPU performance testing tool
  2060. apt-get install mesa-utils
  2061. glxgears
  2062. # command-line based download accelerator
  2063. sudo apt-get install axel
  2064. axel https://releases.ubuntu.com/20.04.2.0/ubuntu-20.04.2.0-desktop-amd64.iso
  2065. # uuencode
  2066. sudo apt-get install sharutils
  2067. # identify (required imagemagick)
  2068. identify -verbose <filename.jpg>
  2069. # ffprobe
  2070. ffprobe <filename.mp3> # information regarding audio file
  2071. # mediainfo
  2072. mediainfo <filename.mp3>
  2073. # sox
  2074. soxi <filename.mp3>
  2075. # unoconv - convert any document from and to any LibreOffice supported format
  2076. # change default cursor theme
  2077. list of cursors theme available:
  2078. crystalcursors dmz-cursor-theme xcursor-themes comixcursors Chamelon-cursor-theme
  2079. installing crystalcursors:
  2080. sudo apt-get install crystalcursors
  2081. run the update-alternative to set/change the current-cursor-theme:
  2082. sudo update-alternatives --config x-cursor-theme
  2083. # hide the cursor pointer
  2084. sudo apt-get install unclutter
  2085. put the following in a script 'unclutter.sh': unclutter -idle 1 -root -grab -visible
  2086. chmod u+x unclutter.sh
  2087. unclutter &
  2088. [add this line to ~/.xinitrc: unclutter &]
  2089. to stop unclutter: sudo killall unclutter
  2090. put "SDL_VIDEO_X11_DGAMOUSE=0" in ~/.profile [Ref: https://wiki.debian.org/unclutter]
  2091. # copy and paste with xclip
  2092. $ xclip -sel clip ~/.ssh/id_ed25519.pub
  2093. $ tail -n 30 logfile.log | xclip -sel clip
  2094. $ pandoc -t html file.md | xclip -sel clip
  2095. $ cat /etc/apt/sources.list | xclip -sel clip
  2096. $ xclip -o -sel clip > file.txt
  2097. # list installed packages in DEB based systems
  2098. apt-cache policy
  2099. /etc/apt/sources.list.d/
  2100. # tar files:
  2101. 1. compress an entire directory /home/saran/Tardirectory/
  2102. $ tar -czvf file.tar.gz /home/saran/Tardirectory/
  2103. 2. compress multiple directories and files:
  2104. $ tar -czvf file.tar.gz /home/saran/Documents/ /home/saran/Music/
  2105. /home/saran/Pictures/image.png
  2106. 3. bzip2 compression instead of gzip by passing -j option:
  2107. $ tar -cjvf file.tar.bz2 /home/saran/Tardirectory/
  2108. 4. exclude files when using tar:
  2109. $ tar -czvf archive.tar.gz --exclude='file.txt' /home/saran/Directory/
  2110. 5. exclude ~/Downloads directory:
  2111. $ tar -czvf /nfs/backup.tar.gz --exclude="Downloads" /home/saran/
  2112. 6. view files stored in an archive:
  2113. $ tar -ztvf file.tar.gz
  2114. $ tar -jtvf file.tar.bz2
  2115. 7. extracting an archive:
  2116. $ tar -xzvf file.tar.gz
  2117. $ tar -xjvf file.tar.bz2
  2118. 8. extract the contents of the archive into a specific directory:
  2119. $ tar -xzvf file.tar.gz -C /home/saran/Backup/
  2120. $ tar -xjvf file.tar.bz2 -C /home/saran/Backup/
  2121. # check ip address in termex: (check for 'UP')
  2122. ip -br addr | grep -v DOWN
  2123. sshd # start ssh demeon in termex
  2124. # ssh to termex:
  2125. ssh -p 8022 u0_a499@192.168.43.128 [5Tw@4rEWn3]
  2126. scp -P 8022 file.tar.gz u0_a499@192.168.43.128:~/Tardirectory/
  2127. scp -v -P 8022 file.tar.gz u0_a499@192.168.43.128:~/Tardirectory/
  2128. ssh -p 8022 u0_a275@192.168.29.121 # realme
  2129. # bootable usb
  2130. sudo mkfs -t vfat /dev/sdb1
  2131. sudo umount /dev/sdb1 /media/user/
  2132. sudo dd bs=4M if=/home/saran/file.iso of=/dev/sdb1 status=progress oflag=sync
  2133. # command
  2134. command ls
  2135. command -V ls
  2136. # check which shells are installed
  2137. cat /etc/shells
  2138. # analsys of text speech
  2139. cat speech.txt | tr ' ' '\n' | tr -d '[:punct:]' | tr '[A-Z]' '[a-z]' | sort | \
  2140. uniq -c | sort -nr | less
  2141. # directory usage
  2142. du -sh * | less
  2143. mv `ls | grep -i 'cheat'` /path/to/directory/
  2144. # number of lines in a file
  2145. nl <filename>
  2146. # graphics card [Ref: https://wiki.debian.org/GraphicsCard]
  2147. If your graphic card was manufactured in 2007 and newer, try uninstalling the
  2148. xserver-xorg-video-intel package and use the builtin modesetting driver xserver-xorg-core
  2149. instead. For older devices: xserver-xorg-video-intel
  2150. # change console font type and size
  2151. In Debian, you can use "console-setup" configuration file for "setupcon" which is used to
  2152. configure font and keyboard layout for the console. The standard location of the
  2153. console-setup configuration file is /etc/default/console-setup
  2154. sudo dpkg-reconfigure console-setup
  2155. # factor
  2156. factor 12
  2157. # hostnamectl
  2158. 1. static hostname
  2159. 2. icon name
  2160. 3. chassis
  2161. 4. machine id
  2162. 5. boot id
  2163. 6. operating system
  2164. 7. kernel
  2165. 8. architecture
  2166. # debian version
  2167. cat /etc/debian_version
  2168. # install kernel headers
  2169. apt-get install linux-headers-$(uname -r)
  2170. # getting started with dpkg
  2171. dpkg --get-selections # listing installed software packages
  2172. dpkg --print-avail # display available version details about installed packages
  2173. dpkg-query --list # display software package information in a tabular form
  2174. sudo dpkg --install ~/Downloads/qutebrowser_amd64.deb # installing software packages
  2175. sudo apt install -f # restoring dependencies
  2176. dpkg --audit # to check for broken packages (missing dependencies)
  2177. sudo dpkg-reconfigure virtualbox-6.1 # re-configuring a software package
  2178. sudo dpkg --remove qutebrowser # removing software package
  2179. sudo dpkg --purge qutebrowser # removing software package and its configurations
  2180. sudo dpkg --info ~/Downloads/qutebrowser_amd64.deb # information about a software package
  2181. dpkg --contents ~/Downloads/qutebrowser_amd64.deb # inspecting software package content
  2182. sudo dpkg --status zathura # finding out if a package is installed
  2183. dpkg --help # to learn more about the dpkg command
  2184. man dpkg # for more detailed info about the dpkg command
  2185. # fslint (whereis fslint) [Note: read man fslint]
  2186. /usr/share/fslint/fslint/findup - find duplicate files
  2187. /usr/share/fslint/fslint/findnl - find name lint (problems with filenames)
  2188. /usr/share/fslint/fslint/findu8 - find filenames with invalid utf8 encoding
  2189. /usr/share/fslint/fslint/findbl - find bad links (various problems with symlinks)
  2190. /usr/share/fslint/fslint/findsn - find same name (problems with clashing names)
  2191. /usr/share/fslint/fslint/finded - find empty directories
  2192. /usr/share/fslint/fslint/findid - find files with dead user IDs
  2193. /usr/share/fslint/fslint/findns - find non stripped executables
  2194. /usr/share/fslint/fslint/findrs - find redundant whitespace in files
  2195. /usr/share/fslint/fslint/findtf - find temporary files
  2196. /usr/share/fslint/fslint/findul - find possibly unused libraries
  2197. /usr/share/fslint/fslint/zipdir - reclaim wasted space in ext2 directory entries
  2198. # check disk partitioning scheme in command line (check system uses MBR or GPT partition)
  2199. sudo parted -l # in the output, look for the line starting with Partition Table
  2200. # check if you are using UEFI or BIOS
  2201. ls /sys/firmware/efi # the directory will be missing if system is using BIOS
  2202. sudo apt-get install efibootmgr
  2203. sudo efibootmgr # to check UEFI or BIOS
  2204. # check whether computer is 32-bit or 64-bit
  2205. lscpu # if 64-bit system, it's better (and recommended) to install 64-bit OS
  2206. uname -m
  2207. arch
  2208. # uname
  2209. uname -s # kernel name
  2210. uname -r # kernel release
  2211. uname -v # kernel version
  2212. uname -n # network node name (hostname)
  2213. uname -m # machine architecture
  2214. uname -p # processor architecture
  2215. uname -i # hardware platform (os architecture)
  2216. uname -o # operating system
  2217. # check weather in terminal
  2218. curl wttr.in/chennai
  2219. # display worldmap in terminal
  2220. telnet mapscii.me
  2221. # view package update history
  2222. grep installed /var/log/dpkg.log
  2223. # view the previous install log
  2224. grep installed /var/log/dpkg.log.l
  2225. # view the archived logs
  2226. zgrep installed /var/log/dpkg.log.2.gz
  2227. # view apt history
  2228. /var/log/apt/history.log
  2229. # cd to raman's home directory
  2230. cd ~raman
  2231. # correct and tidy up the markup of HTML, XHTML, and XML files
  2232. tidy file.html
  2233. # print sensor chips information (e.g. temperature)
  2234. sensors
  2235. # perf - performance analysis tools for linux
  2236. sudo apt-get install linux-perf
  2237. sudo sh -c 'echo 1 > /proc/sys/kernel/perf_event_paranoid' # run perf as normal user
  2238. # performance counters of a program using perf
  2239. perf stat -e cycles,instructions,cache-references,cache-misses,branches,branch-misses,\
  2240. task-clock,faults,minor-faults,cs,migrations python program.py
  2241. # using cat to edit a file
  2242. cat > filename # edit a file
  2243. cat >> filename # append to a file
  2244. ctrl + D # save and exist the file
  2245. # display file size
  2246. ls -sh filename
  2247. du -sh filename
  2248. # find the MAC address
  2249. ip addr sh [lint/ether MACID]
  2250. ip link show [link/ether MACID]
  2251. sudo lshw -C network [serial: MACID]
  2252. # network interface [/etc/network/interfaces] [/etc/network/interfaces.d/setup]
  2253. ## The loopback network interface
  2254. auto lo
  2255. iface lo inet loopback
  2256. ## The eno1 network interface
  2257. auto eno1
  2258. allow-hotplug eno1
  2259. iface eno1 inet dhcp
  2260. ## The enp0s20u1 network interface
  2261. auto enp0s20u1
  2262. allow-hotplug enp0s20u1
  2263. iface enp0s20u1 inet dhcp
  2264. ## The enp0s20u2 network interface
  2265. auto enp0s20u2
  2266. allow-hotplug enp0s20u2
  2267. iface enp0s20u2 inet dhcp
  2268. # "no public key available" on apt-get update [Ref: https://keyring.debian.org/]
  2269. Debian Public Key Server
  2270. gpg --keyserver keyring.debian.org --recv-keys <PUBLIC KEY>
  2271. # To run history event number 1, type:
  2272. $ !1
  2273. # find the number of CPU cores
  2274. cat /proc/cpuinfo
  2275. # find the number of physical CPUs
  2276. cat /proc/cpuinfo | grep "^physical id" | sort | uniq | wc -l
  2277. # find the number of cores per CPU
  2278. cat /proc/cpuinfo | grep "^cpu cores" | uniq
  2279. # find the total number of processors
  2280. cat /proc/cpuinfo | grep "^processor" | wc -l
  2281. # to check which program is using a port
  2282. sudo lsof -i:<port_number> -n -P
  2283. # to list all open TCP ports along with their associated process
  2284. sudo lsof -i -n -P | grep TCP
  2285. # enable X11 forwarding using SSH
  2286. X11 forwarding is a mechanism that allows graphical interfaces of X11 programs running on
  2287. a remote server to be displayed on a local client machine.
  2288. ## Server-side preparation:
  2289. sudo apt-get install xauth
  2290. Enable X11 forwarding system-wide:
  2291. sudo vi /etc/ssh/sshd_config
  2292. X11Forwarding yes
  2293. sudo /etc/init.d/sshd restart
  2294. Enable X11 forwarding on a per-user basis:
  2295. vi $HOME/.ssh/config
  2296. ForwardX11 yes
  2297. ## Client-side test
  2298. Unlike a remote server host, a local client machine needs to have X11 system installed.
  2299. ssh -X user@remote_server
  2300. # speed up X11 forwarding in SSH over wide area networks
  2301. use less computation heavy ciphers in SSH, the default 'AES' cipher used by OpenSSH is
  2302. known to be slow. 'arcfour' and 'blowfish' ciphers are faster than 'AES'. 'blowfish' is a
  2303. fast block cipher which is also very secure, 'arcfour' stream cipher is known to be nore
  2304. vulnerable than common block ciphers.
  2305. $ ssh -XC -c blowfish-cbc,arcfour user@remote_server
  2306. ## specify these options in an SSH configuration file
  2307. to edit system-wide SSH configuration file
  2308. $ sudo vi /etc/ssh/ssh_config
  2309. to edit per-user SSH configuration file
  2310. $ vi ~/.ssh/config
  2311. in either SSH configuration file, add the following:
  2312. Host remote_server
  2313. Compression yes
  2314. ForwardX11 yes
  2315. Ciphers blowfish-cbc,arcfour
  2316. then SSH to the remote host without using any command-line options
  2317. $ ssh user@remote_server
  2318. Note that there are some caveats in switching to a different cipher in SSH. The
  2319. performance of a particular cipher may vary across different processor architecture. In
  2320. recent generations of Intel processors come with hardware support for 'AES'.
  2321. # build RPM or DEB package from the source with checkinstall
  2322. installating a linux program from its source by running 'make install', it becomes really
  2323. tricky to remove it completely, unless the author of the program provides an uninstall
  2324. target in the Makefile.
  2325. installing checkinstall in debian
  2326. sudo apt-get install checkinstall
  2327. build an DEB package with checkinstall
  2328. sudo ./configure
  2329. sudo checkinstall
  2330. # check battery status using command line
  2331. cat /sys/class/power_supply/BAT0/capacity # for the battery capacity
  2332. find /sys/class/power_supply/BAT0/ -type f | xargs -tn1 cat # detailed battery info
  2333. Ref: https://www.linuxjournal.com/content/how-check-battery-status-using-linux-command-line
  2334. # scan IP address connected to the network
  2335. sudo nmap -sn <ip address being used locally>
  2336. Example: sudo nmap -sn 192.168.30.0/22
  2337. # nmap commands
  2338. nmap 192.168.1.1
  2339. sudo nmap -O -Pn 192.168.1.1
  2340. nmap -Pn -p 22,24 192.168.1.1
  2341. nmap -F 192.168.1.1
  2342. nmap -Pn --open 192.168.1.1
  2343. # display file system type
  2344. df -Th
  2345. sudo fsck -N /dev/sda1
  2346. lsblk -f
  2347. sudo file -sL /dev/sda1
  2348. # df commands to check disk space
  2349. df # check file system disk space usage
  2350. df -a # display information of all file system disk space usage
  2351. df -h # show disk space usage in human readable format
  2352. df -hT /home # display information of /home file system
  2353. df -k # display information of file system in bytes
  2354. df -m # display information of file system in MB
  2355. df -h # display information of file system in GB
  2356. df -i # display file system inodes
  2357. df -T # display file system type
  2358. df -t ext3 # include certain file system type
  2359. df -x ext3 # exclude certain file system type
  2360. df --help # display information of df command
  2361. # system and hardware info
  2362. uname # system name
  2363. uname -s # kernel name
  2364. uname -n # network hostname
  2365. uname -v # kernel version
  2366. uname -r # kernel release
  2367. uname -m # machine hardware name
  2368. uname -a # all the above info
  2369. sudo lshw # print information about Linux system hardware
  2370. sudo lshw -short # print a summary of hardware information
  2371. sudo lshw -html > lshw.html # generate output as html file
  2372. lscpu # information about CPU
  2373. lsblk # information about block devices
  2374. lsblk -a # view all block devices on system
  2375. lsusb # information about USB controllers and all devices connected
  2376. lsusb -v # generate detailed information about each USB device
  2377. lspci # print information about PCI devices
  2378. lspci -t # produce output in tree format
  2379. lspci -v # produce detailed information about each connected device
  2380. lsscsi # print SCSI devices information
  2381. lsscsi -s # show device sizes
  2382. sudo hdparm /dev/sda1 # information about sata devices on system
  2383. sudo hdparm -g /dev/sda1 # information about device geometry
  2384. sudo fdisk -l # information file system partitions
  2385. sudo dmidecode -t memory # print information about memory
  2386. sudo dmidecode -t system # print information about system
  2387. sudo dmidecode -t bios # print information about bios
  2388. sudo dmidecode -t processor # print information about processor
  2389. # print how many seconds the current shell has been running
  2390. echo $SECONDS
  2391. units '1624 seconds' 'minutes'
  2392. # outputing a random number
  2393. echo $RANDOM
  2394. yes `echo $RANDOM`
  2395. # controlling processes
  2396. ps # list of the processes running on system
  2397. ps -aux # list all running processes
  2398. ps -a # list all processors from all users
  2399. ps -u # list more information including user names, %cpu usage, and %mem usage etc
  2400. ps -x # list processes without controlling terminals
  2401. ps -l # display information including UID and nice value
  2402. ps --forest # to see the process hierarchy
  2403. pstree # displays the processes in the form of a tree structure
  2404. pgrep <process_name> # finding the process id of a particular process
  2405. pgrep -u <user_name> -l <process_name> # find the process id of particular process by user
  2406. # command to find function meanings
  2407. declare
  2408. # network manager
  2409. sudo apt-get install network-manager
  2410. sudo systemctl restart network-manager
  2411. # make unmanaged network interface to connected with nmcli
  2412. [check first if the ip address is displayed then follow the steps below]
  2413. nmcli dev status # if [device] eno1 [type] ethernet [state] unmanaged
  2414. sudo vi /etc/NetworkManager/NetworkManager.conf
  2415. [ifupdown]
  2416. managed=true # change managed=false to managed=true
  2417. sudo systemctl restart network-manager # restart the network manager
  2418. nmcli dev status # check the interface status
  2419. ping -c 3 startpage.com # check if able to ping
  2420. # exit an unresponsive ssh session without closing the terminal
  2421. press [Enter] ----> press [~] ----> press [.]
  2422. # recursively lists package dependencies
  2423. apt-rdepends <package_name>
  2424. # check installed architectures
  2425. # verify 64-bit architecture
  2426. dpkg --print-architecture # should respond with "amd64"
  2427. # verify if 32-bit architecture is already installed
  2428. dpkg --print-foreign-architectures # should respond with "i386"
  2429. # if it does not display "i386"
  2430. sudo dpkg --add-architecture i386
  2431. # re-check
  2432. dpkg --print-foreign-architectures
  2433. # convert-im6.q16: attempt to perform an operation not allowed by the security policy
  2434. ImageMagick disables many ghostscript format types.
  2435. This can be seen in the file: /etc/ImageMagick-6/policy.xml
  2436. <!-- disable ghostscript format types -->
  2437. <policy domain="coder" rights="none" pattern="ps" />
  2438. <policy domain="coder" rights="none" pattern="EPS" />
  2439. <policy domain="coder" rights="none" pattern="PDF" />
  2440. <policy domain="coder" rights="none" pattern="XPS" />
  2441. Modify this to allow: rights="read"
  2442. # transform a text file into an image
  2443. convert -size 360x360 xc:white -font "FreeMono" -pointsize 12 -fill black
  2444. -draw @file.txt image.png
  2445. convert -size 360x360 xc:white -font "FreeMono" -pointsize 12 -fill black
  2446. -annotate +15+15 @file.txt image.png
  2447. convert -size 1000x2000 xc:white -font "FreeMono" -pointsize 12 -fill black
  2448. -annotate +15+15 @file.txt -trim -bordercolor "#FFF" -border 10 +repage img.png
  2449. convert -list font # display all of the possible arguments to -font
  2450. Reference:
  2451. https://unix.stackexchange.com/questions/138804/how-to-transform-a-text-file-
  2452. into-a-picture
  2453. # manually installing Xorg (https://adercon.com/posts/manually-installing-xorg)
  2454. Xorg install with a simple 'apt-get install xorg' pulls in all drivers - most
  2455. of which not need and install Xorg in a minimalistic approach.
  2456. First need to find the video card (and driver) for the video card:
  2457. * find video card: lspci | grep -i 'vga'
  2458. The result of the above command should be something similar to the following:
  2459. 00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor
  2460. Graphics Controller (rev 09)
  2461. In the above output, "00:02.0" is the device id.
  2462. * get card details: lspci -v -s DEVICE-ID
  2463. The above command should return something similar to the following:
  2464. 00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor
  2465. Graphics Controller (rev 09) (prog-if 00 [VGA controller])
  2466. Subsystem: Hewlett-Packard Company 3rd Gen Core processor Graphics Controller
  2467. Flags: bus master, fast devsel, latency 0, IRQ 29
  2468. Memory at c3000000 (64-bit, non-prefetchable) [size=4M]
  2469. Memory at b0000000 (64-bit, prefetchable) [size=256M]
  2470. I/O ports at 5000 [size=64]
  2471. [virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
  2472. Capabilities: <access denied>
  2473. Kernel driver in use: i915
  2474. Kernel modules: i915
  2475. * you want to note the vendor ("Intel Corporation")
  2476. and the kernel driver ("1915")
  2477. * now install Xorg with the following:
  2478. apt-get install xserver-xorg-core xserver-xorg-input-all
  2479. xserver-xorg-video-fbdev xserver-xorg-video-(yourcard:
  2480. can be intel, nouveau, or ati)
  2481. # remove all Xorg
  2482. The following code will remove xorg, display managers, etc. and leave you
  2483. with a more clean/trim server:
  2484. apt-get remove --purge xorg*
  2485. apt-get remove --purge nautilus*
  2486. apt-get remove --purge desktop-base
  2487. apt-get remove --purge python-gnome*
  2488. apt-get remove --purge gdm3
  2489. apt-get remove --purge x11-*
  2490. apt-get remove --purge gnome-*
  2491. apt-get autoremove --purge
  2492. # cleanup unused package configs
  2493. # (https://adercon.com/posts/cleanup-unused-package-configs/)
  2494. apt-get purge `dpkg --get-selections | grep deinstall | cut -f1`
  2495. # Possible missing firmware /lib/firmware/rtl_nic/rtl8105e-1.fw of module r8169
  2496. sudo apt-get install firmware-realtek
  2497. Ref:
  2498. https://unix.stackexchange.com/questions/682990/linux-upgrade-debian-possible-
  2499. missing-firmware-problem
  2500. # for info on Graphics
  2501. inxi -G
  2502. # convert epub to pdf
  2503. https://ebook.online-convert.com/convert-to-pdf
  2504. Base font size: 10
  2505. Embed font: Serif
  2506. Change input encoding: Automatic detection
  2507. Enable ASCII output
  2508. Enable heuristics
  2509. Target ebook reader: Default
  2510. Add border: 0-20 cm
  2511. # patching st terminal
  2512. $ git clone https://git.suckless.org/st
  2513. $ mv st/ .st/
  2514. $ cd .st/
  2515. $ wget https://st.suckless.org/patches/anysize/st-expected-anysize-0.9.diff
  2516. $ patch -Np1 -i st-expected-anysize-0.9.diff (in directory ~/.st/)
  2517. $ doas make clean install [Note: edit config.h before make clean install]
  2518. # tmux not sourcing my .tmux.conf
  2519. Binding keys in tmux: https://www.seanh.cc/2020/12/28/binding-keys-in-tmux/
  2520. tmux ls
  2521. tmux kill-server
  2522. Ref:
  2523. https://unix.stackexchange.com/questions/66606/tmux-not-sourcing-my-tmux-conf/
  2524. # mod + ctrl + (workspace)
  2525. # top command options
  2526. top # to launch top
  2527. press the z key # to change the color of the output
  2528. press the 1 key # to see a graphical representation of each CPU core
  2529. press the m key # display memory usage graphically
  2530. top -u 'username' # display processes started by a specific user
  2531. top -i # list of idle processes on your system
  2532. top -d 5 # update interval to an arbitrary value in seconds
  2533. top -n 2 # number of iterations to two and then exits
  2534. Press 'shift + L' to locate a process by name. This creates a prompt just above
  2535. the bold table header line. Type in the name of the process you're looking for
  2536. and then press 'Enter' to see the instances of that process highlighted in the
  2537. newly sorted process list.
  2538. Stop or 'kill' a running process. Find the process you want to stop using
  2539. 'shift + L'. Next, press K and enter the process ID you want to stop.
  2540. Ref: https://opensource.com/article/22/3/linux-top-command
  2541. # change font type and size in st terminal
  2542. st -f "Inconsolata:style=Regular:size=14"
  2543. # compare two files
  2544. cmp file1.txt file2.txt # if file1.txt == file2.txt then no output printed
  2545. # display the differences between two files
  2546. diff file1.txt file2.txt # if file1.txt == file2.txt then no output printed
  2547. # croping pdf file
  2548. pdfcrop --margins '-100 -15 -100 -490' input.pdf output.pdf
  2549. # google sign-in issues
  2550. for versions between v1.10.0 (inclusive) and v2.3.1 (exclusive), run
  2551. :set -u https://accounts.google.com/* content.headers.user_agent
  2552. "Mozilla/5.0 ({0s_info}; rv:90.0) Gecko/20100101 Firefox/90.0" for versions
  2553. between v1.2.0 (inclusive) and v1.10.0 (exclusive), use X11; Linux x86_64 in
  2554. place of {os_info}.
  2555. # config in qutebrowser
  2556. :set zoom.default 70
  2557. :set url.start_pages "https://startpage.com/{}"
  2558. ~/.config/qutebrowser/config.py
  2559. config.load_autoconfig()
  2560. c.url.start_pages = ["https://startpage.com/{}"]
  2561. c.url.searchengines = {
  2562. "DEFAULT": "https://startpage.com/{}"
  2563. }
  2564. # install liberation mono (https://wiki.debian.org/Fonts)
  2565. sudo apt-get install fonts-liberation/fonts-liberation2
  2566. # ssh
  2567. sudo apt-get update
  2568. sudo apt-get install openssh-server
  2569. sudo systemctl status ssh
  2570. sudo systemctl start ssh # in case not started, start ssh service
  2571. sudo systemctl enable ssh # to enable the ssh service on system boot
  2572. ssh saravanan@10.21.106.28 # login the remote machine
  2573. # scp
  2574. scp file.txt saravanan@10.21.106.28:~/Documents/ # copy local file to remote
  2575. scp saravanan@10.21.106.28:~/Documents/file.txt /home/saran/ # remote to local
  2576. # find number of CPU cores
  2577. nproc command shows the number of processing units available
  2578. $ nproc
  2579. lscpu gathers CPU architecture information from /proc/cpuinfo in human-readable
  2580. $ lscpu
  2581. /proc/cpuinfo and sysfs stores info about CPU architecture like number of CPUs,
  2582. threads, cores, sockets, NUMA nodes, information about CPU caches, CPU family
  2583. less /proc/cpuinfo
  2584. # youtube-dl
  2585. xclip -o -selection clipboard > url.txt
  2586. youtube-dl -F $(< url.txt)
  2587. youtube-dl -f bestaudio+bestvideo $(< url.txt)
  2588. # list of sound cards
  2589. $ cat /proc/asound/cards
  2590. $ lspci | grep -i audio
  2591. $ aplay --list-devices
  2592. # setting the default device sound card
  2593. Find your desired card with:
  2594. $ cat /proc/asound/cards
  2595. and then create /etc/asound.conf with following:
  2596. defaults.pcm.card 1
  2597. defaults.ctl.card 1
  2598. Note: Replace "1" with number of your card determined above.
  2599. Ref: https://www.alsa-project.org/wiki/Setting_the_default_device
  2600. -----------------------------
  2601. SOFTWARE | Applications |
  2602. -----------------------------
  2603. |
  2604. -----------------------------
  2605. | PipeWire | JACK |
  2606. SYSTEM SOFTWARE -----------------------------
  2607. SOUND SERVERS | PulseAudio |
  2608. -----------------------------
  2609. |
  2610. -----------------------------
  2611. | Advanced Linux |
  2612. KERNEL, DRIVERS | Sound Architecture |
  2613. | (ALSA) |
  2614. -----------------------------
  2615. |
  2616. -----------------------------
  2617. | Equalizer | Sound board |
  2618. -----------------------------
  2619. HARDWARE | Mixer | Sound card |
  2620. -----------------------------
  2621. | ... |
  2622. -----------------------------
  2623. # enable sound in debian linux
  2624. $ doas apt-get install alsa-utils
  2625. $ alsamixer
  2626. press F6 to select sound card [HDA Intel PCH]
  2627. Ref: https://vitux.com/how-to-control-audio-on-the-debian-command-line/
  2628. # using amixer to control audio properties through commands
  2629. $ amixer --help
  2630. $ amixer -c [card-number] set [control] [value] # amixer command example
  2631. $ amixer scontrols # view the list of controls
  2632. $ amixer -c 0 set Master 100% # set the volume on the Master of 1st sound card to 100%
  2633. $ amixer -c 1 set Speaker 50% # set the volume on the Speaker of 2nd sound card to 50%
  2634. $ amixer -c 1 set Speaker 3db # set the volume on the Speaker of 2nd sound card to 3db
  2635. $ amixer -c 1 set Speaker 2db+ # increase the volume on the Speaker of 2nd card by 2db
  2636. $ amixer -c 0 set Mic mute # mute the Mic of 1st sound card
  2637. $ amixer -c 0 set Mic unmute # unmute the Mic of 1st sound card
  2638. # pipewire
  2639. $ doas apt-get install pipewire-audio
  2640. # change cursor theme
  2641. /usr/share/icons/default/index.theme
  2642. /usr/share/icons/Adwaita/cursor.theme
  2643. # git commands
  2644. git config
  2645. git config --global init.defaultBranch master
  2646. # remove welcome screen text in termux
  2647. Open termux app and type:
  2648. cd ../usr/etc/
  2649. rm motd
  2650. # Fonts
  2651. # Console /usr/share/consolefonts/Lat15-Fixed16.psf.gz
  2652. Encoding to use on the console: UTF-8
  2653. Please choose the character set that should be supported by the console font:
  2654. Latin1 and Latin5 - western Europe and Turkic languages
  2655. Font for the console: Fixed
  2656. Font size: 8x16
  2657. # St terminal
  2658. apt-get install fonts-unifont
  2659. st -f "Unifont:pixelsize=16:antialias=true:autohint=true"
  2660. # set console fonts
  2661. setfont /usr/share/consolefonts/Lat15-Fixed16.psf.gz
  2662. # commandline system information
  2663. inxi --recommends # after installation check dependencies & directories
  2664. inxi # show linux system information
  2665. inxi -S # show linux kernel and distribution info
  2666. inxi -M # show linux machine information
  2667. inxi -C # show CPU and CPU speed information
  2668. inxi -G # show graphic card information
  2669. inxi -A # show audio/sound card information
  2670. inxi -N # show network card information
  2671. inxi -D # show hard disk information
  2672. inxi -b # summarize full system information
  2673. inxi -p # show hard disk partition details
  2674. inxi -F # show full system information
  2675. inxi -I # monitor linux processes memory usage
  2676. inxi -t c # monitoring processes by CPU usage
  2677. inxi -t m # monitoring processes by memory usage
  2678. inxi -t cm # monitoring processes by CPU and memory usage
  2679. inxi -t cm10 # monitoring top 10 most active processes eating CPU and memory
  2680. inxi -Nni # monitor linux network interfaces
  2681. inxi -s # monitor linux CPU temperature and fan speed
  2682. inxi -w # show weather report (inxi -W Tokyo,Japan)
  2683. inxi -r # show all linux repository information
  2684. inxi -B # show battery information
  2685. inxi -V # show inxi version
  2686. inxi -h # show inxi help
  2687. # get the GPU information
  2688. sudo lshw -C display # shows product, vendor, physical id, bus info, clock
  2689. glxinfo # OpenGL information for the graphics processor
  2690. nvidia-smi # show information for nvidia gpu
  2691. lspci | grep -i 'nvidia'# device id of VGA compatible controller & audio device
  2692. cat /proc/driver/nvidia/gpus/<device id>/information # gpu model and uuid
  2693. nvidia-smi -q # display more detailed gpu information
  2694. nvidia-smi --list-gpus # list names of the video cards on the machine
  2695. gpustat -cp # gpu memory information
  2696. # installing custom fonts
  2697. * create a folder .fonts in $HOME directory
  2698. * download fonts of choice (ttf or odf format to ~/.fonts)
  2699. * refresh the fonts cache with fc-cache -fv
  2700. * verify if fonts got added to the cache using fc-list
  2701. example: fc-list -f "%{family}\n" | sort -u | grep -i 'inconsolata'
  2702. # system reboot with users logedin
  2703. systemctl reboot -i
  2704. # finding nvidia cuda version
  2705. nvcc --version # nvidia cuda compiler
  2706. nvidia-smi # to check CUDA version
  2707. cat /usr/lib/cuda/version.txt (find /usr -type d -name cuda; whereis cuda)
  2708. cat "$(dpkg -L nvidia-cuda-toolkit | grep 'version.txt')"
  2709. apt info nvidia-cuda-toolkit
  2710. # check nvidia driver supports kernel version
  2711. uname -r
  2712. dkms status
  2713. apt-cache policy nvidia-driver-470
  2714. # nvidia driver is not loaded
  2715. sudo prime-select nvidia
  2716. sudo reboot
  2717. # soft link creation for nvcc
  2718. sudo ln -s /usr/local/cuda-11.4/bin/nvcc /usr/bin/nvcc
  2719. # issue: # updates could not be installed automatically.
  2720. For more details, see /var/log/unattended-upgrades/unattended-upgrades.log
  2721. Find the pin in /etc/apt/preferences.d: ls /etc/apt/preferences.d
  2722. We can obtain the packages that have been kept back:
  2723. /var/lib/unattended-upgrades/kept-back
  2724. solution 1: sudo apt-get --with-new-pkgs upgrade
  2725. solution 2: sudo apt-get install nvidia-driver-470
  2726. solution 3: sudo apt-get dist-upgrade
  2727. solution 4: sudo apt purge cuda*
  2728. sudo rm /etc/apt/preferences.d/cuda-repository-pin-600
  2729. sudo apt autoremove
  2730. sudo apt autoclean
  2731. using apt-get install <pkg> instead will mark <pkg> as 'manually installed !'
  2732. to mark it again as 'automatically installed' use apt-mark auto <pkg>
  2733. Ref: https://askubuntu.com/questions/601/the-following-packages-have-been-kept-
  2734. back-why-and-how-do-i-solve-it
  2735. https://askubuntu.com/questions/1344136/unattended-upgrades-could-not-be-
  2736. installed-automatically
  2737. profiling python program
  2738. # Failed to connect to https://changelogs.ubuntu.com/meta-release-lts.
  2739. # Check your Internet connection or proxy settings.
  2740. sudo truncate -s 0 /var/lib/ubuntu-release-upgrader/release-upgrade-available
  2741. # aptitude safe-upgrade instead of apt-get dist-upgrade
  2742. sudo aptitude safe-upgrade
  2743. # fonts selection
  2744. fc-match sans-serif
  2745. fc-match serif
  2746. fc-match monospace
  2747. # convert pdf to jpg
  2748. pdftoppm -jpeg -r 300 file.pdf output
  2749. # darkweb definition (Ref: page: 6, Weaving the Dark Web)
  2750. Although Freenet, Tor and I2P implement anonymous web technologies in very
  2751. different ways, they all provide readers and publishers with anonymity by
  2752. allowing them to browse and publish anonymous websites. Here, the connotation
  2753. of "darkness" in Dark Web has more to do with encryption, annonymization, and
  2754. leaving standard communications channels (as in the phrase used by James Comey,
  2755. "going dark", meaning avoiding overly public communications channels). "Web"
  2756. refers, of course, to websites, web browsers, HTML, and CSS.
  2757. If anything, the Dark Web functions much like the regular web - with the key
  2758. exception that one needs special routing software to access it, software that
  2759. can protect the identity of site readers and publishers. It is not deeper than
  2760. the regular web in any logical sense.
  2761. # xterm
  2762. xterm -bg black -fg white -fa 'Iosevka' -fs 10
  2763. # bash shell tricks
  2764. Ctrl + x and Ctrl + V # find the version of the bash shell
  2765. type $ and press tab key twice # system environment variables
  2766. type ~ and press tab key twice # show all user from /etc/passwd file
  2767. s=$((5*5)) then type echo $s # arithmetic operation in bash shell
  2768. PS1="$ " # change the bash shell prompt by assigning PS1 variable
  2769. env | less # show the environment
  2770. set | less # display the names and values of shell variables
  2771. # paste in st terminal
  2772. Ctrl + Shift + V
  2773. # removing password from pdf file
  2774. gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputfile=unencrypted.pdf -c
  2775. .setpdfwrite -f encrypted.pdf
  2776. # regex
  2777. $ cd nmsc
  2778. $ find . -regex ".*leg\.py"
  2779. ./scripts/python/gaussquad/gaussleg.py
  2780. ./Endsem/Scripts/gaussleg.py
  2781. This search tells find to start from the current directory (the ".") and find
  2782. all files that have zero or more characters (the ".*") before the string "leg",
  2783. which comes before the "." (which must be escaped because "." normally means
  2784. "any single character"), followed by the file extension of python.
  2785. # list namespaces
  2786. $ sudo lsns
  2787. # build html file from rst file
  2788. $ rst2html5.py --link-stylesheet --cloak-email-addresses --toc-top-backlinks
  2789. --stylesheet=book.css --stylesheet-dirs=. book.rst
  2790. # grammer-check a text file
  2791. $ diction textfile.txt | less
  2792. # grammer checking using gramma (install with nodejs npm)
  2793. # check file
  2794. gramma check [file] # interactive fix
  2795. gramma check -p [file] # just print potential mistakes and return status code
  2796. # check string
  2797. gramma listen [text] # interactive fix
  2798. gramma listen -p [text] # just print potential mistakes and return status code
  2799. # apt-cache search lisp scheme
  2800. scm - Scheme language interpreter
  2801. sloccount - programs for counting physical source lines of code (SLOC)
  2802. src2tex - converter from source program files to TeX format files
  2803. texify - Beautify source code for use with LaTeX
  2804. # set the date for 02:07:30 PM on August 19 without changing the year
  2805. $ sudo date 08191407.30
  2806. # find difference between two directories using diff
  2807. To know what files/subdirectories are common in the two directories, those that
  2808. are present in one directory but not in the other. The conventional syntax for
  2809. running diff is as follows:
  2810. $ diff directory1/ directory2/
  2811. By default, its output is ordered alphabetically by files/subdirectory name. In
  2812. this command, the -q switch tells diff to report only when files differ.
  2813. $ diff -q directory1/ directory2/
  2814. Again diff doesn't go into the subdirectories, but we can use the -r switch to
  2815. read the subdirectories as well.
  2816. $ diff -qr directory1/ directory2/
  2817. # numactl
  2818. $ numactl --hardware
  2819. $ numactl --show
  2820. # linux malware incident response tools
  2821. netcat - arbitrary TCP and UDP connections and listens
  2822. cryptcat - twofish encryption enabled version of nc
  2823. memdump - memory dumper
  2824. dc3dd - convert and copy a file
  2825. linuxinfo - displays system information about system
  2826. logname - print user's login name
  2827. printenv - print all or part of environment
  2828. acct - switch process accounting on or off
  2829. fuser - identify processes using files or sockets
  2830. route - route traffic control filter
  2831. procinfo - tools to display information from /proc and /sys
  2832. pslist - utility that controls a process and its descendants
  2833. ss - another utility to investigate sockets
  2834. users - print the user names of users currently logged in to the current host
  2835. w - show who is logged on and what they are doing
  2836. w --ip-addr - display IP address instead of hostname for from field
  2837. w <username> - show information about the specified user only
  2838. moreutils - additional unix utilities (ifdata, ifne, isutf8, lckdo, parallel)
  2839. # remove logo with the ffmpeg delogo
  2840. ffplay input.mp4 -vf "delogo=x=1400:y=20:w=500:h=480:show=1"
  2841. # combine/concat multiple audio tracks into single audio
  2842. ffmpeg -f concat -safe 0 -1 list.txt audio.mp3
  2843. list.txt contains paths to all segments:
  2844. file audiofile1.mp3
  2845. file audiofile2.mp3
  2846. file audiofile3.mp3
  2847. # combine one image + one audio file to make one video using ffmpeg
  2848. ffmpeg -r 1 -loop 1 -i image.jpg -i audio.mp3 -acodec copy -r 1 -shortest -vf
  2849. scale=1280:720 video.mp4
  2850. # combine/concat multiple video files into single video
  2851. ffmpeg -f concat -i list.txt video.mp4
  2852. list.txt contains paths to all segments:
  2853. file videofile1.mp4
  2854. file videofile2.mp4
  2855. file videofile3.mp4
  2856. # 32 bits or 64 bits
  2857. $ getconf LONG_BIT
  2858. # list all bash shortcuts
  2859. $ bind -P
  2860. # quick access to ASCII code of a key
  2861. $ showkey --ascii # display the decimal/octal/hex values of the keys
  2862. # simulate typing
  2863. echo "You can simulate on-screen typing just like in the movies" | pv -qL 10
  2864. # set audible alarm when an IP address comes online
  2865. ping -i 60 -a IP_address
  2866. # base conversions with bc
  2867. $ echo "obase=2; 27" | bc -l
  2868. # identify long lines in a file
  2869. $ awk 'length>80' file.txt
  2870. # find if the command has an alias
  2871. $ type -all <command> | grep aliased
  2872. # dictionaries with dict command (http://www.dict.org/)
  2873. Install dict on Linux:
  2874. $ sudo apt-get install dictd dict-gcide
  2875. No additional configuration is required. The minimalistic
  2876. /usr/share/doc/dictd/dict1.conf file specifies the remote server for the
  2877. dictionary databases. This tool uses the Dictionary Server Protocol (DCT) on
  2878. port 2628.
  2879. In a terminal session as a non-root user, type dict <word> to get a list of
  2880. definitions from one or more dictionaries and the thesaurus.
  2881. $ dict <word> | less
  2882. You can also look up multi-word phrases by enclosing them in quotes, either
  2883. double or single.
  2884. $ dict 'air gapped'
  2885. The dict command uses several online dictionaries, including legal & technical
  2886. ones. Dictionaries are also available for many languages. You can list the
  2887. available dictionary databases as shown here:
  2888. $ dict -D | less
  2889. You can specify individual dictionaries with the -d option:
  2890. $ dict -d gcide
  2891. # sharing linux terminals with tmux
  2892. [https://www.admin-magazine.com/HPC/Articles/Sharing-Linux-Terminals]
  2893. $ tmux new -s remote
  2894. tmux new, starts a new session, with the name of the session, remote, placed
  2895. after the -s flag.
  2896. # yt-dlp
  2897. Download the latest version of yt-dlp from GitHub repository:
  2898. with curl:
  2899. $ doas curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp
  2900. -o /usr/local/bin/yt-dlp
  2901. with wget:
  2902. $ doas wget -qO /usr/local/bin/yt-dlp
  2903. https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp
  2904. $ doas chmod a+rx /usr/local/bin/yt-dlp
  2905. $ yt-dlp --help
  2906. $ yt-dlp --version
  2907. $ doas yt-dlp --update
  2908. $ yt-dlp --list-formats "$(< url.txt)"
  2909. $ yt-dlp -f 'bv*+ba/b' "$(< url.txt)"
  2910. $ doas rm -rf /usr/local/bin/yt-dlp # uninstall yt-dlp
  2911. Reference: https://linuxconfig.org/yt-dlp-vs-youtube-dl
  2912. # yt-dlp commands
  2913. 1. To keep the program up to date, use the -U option
  2914. $ yt-dlp -U
  2915. 2. View the available formats and resolutions of a video with the --list-formats
  2916. option
  2917. $ yt-dlp --list-formats <url>
  2918. 3. Download the highest quality video stream and the highest quality audio
  2919. stream for a video, and combine them into a single file
  2920. $ yt-dlp -f 'bv*+ba' <url>
  2921. 4. Download 1080p video quality and combine it with the best possible audio
  2922. stream
  2923. $ yt-dlp -f 'bv*[height=1080]+ba' <url>
  2924. 5. Save only the audio stream (best quality possible) and put into an mp3 file
  2925. $ yt-dlp -f 'ba' -x --audio-format mp3 <url>
  2926. 6. Playlist video to start at (default is 1)
  2927. $ yt-dlp --playlist-start NUMBER <url>
  2928. 7. Playlist video to end at (default is last)
  2929. $ yt-dlp --playlist-end NUMBER <url>
  2930. 8. Playlist video items to download
  2931. $ yt-dlp --playlist-items 1-3,7,10-13 <url> [index: 1, 2, 3, 7, 10, 11, 12, 13]
  2932. # report the number of hyperthreads
  2933. grep processor /proc/cpuinfo
  2934. grep -c processor /proc/cpuinfo
  2935. # find exact linux installation date and time
  2936. 1. using stat command (stat command is part of GNU coreutils package)
  2937. $ stat / | grep 'Birth' | sed 's/Birth: //g' | cut -b 2-11
  2938. $ stat / | awk '/Birth: /{print $2}'
  2939. $ stat -c %w /
  2940. 2. analyze pacman logs on arch linux
  2941. $ head -n1 /var/log/pacman.log
  2942. 3. check syslog entries on debian-based systems
  2943. $ sudo head -n1 /var/log/installer/syslog
  2944. # physical cpu cores vs logical cpu cores
  2945. (https://unix.stackexchange.com/questions/88283/
  2946. so-what-are-logical-cpu-cores-as-opposed-to-physical-cpu-cores)
  2947. $ lscpu
  2948. Architecture: i686
  2949. CPU op-mode(s): 32-bit, 64-bit
  2950. Byte Order: Little Endian
  2951. Address sizes: 36 bits physical, 48 bits virtual
  2952. CPU(s): 2
  2953. On-line CPU(s) list: 0,1
  2954. Thread(s) per core: 1
  2955. Core(s) per socket: 2
  2956. Socket(s): 1
  2957. Vendor ID: GenuineIntel
  2958. CPU family: 6
  2959. Model: 42
  2960. Model name: Intel(R) Pentium(R) CPU B950 @ 2.10GHz
  2961. Stepping: 7
  2962. CPU MHz: 798.120
  2963. CPU max MHz: 2100.0000
  2964. CPU min MHz: 800.0000
  2965. BogoMIPS: 4190.20
  2966. L1d cache: 64 KiB
  2967. L1i cache: 64 KiB
  2968. L2 cache: 512 KiB
  2969. L3 cache: 2 MiB
  2970. * In the above Intel(R) Pentium(R) laptop has 2 "CPUs" in total.
  2971. CPU(s): 2
  2972. * Of which there are 2 physical cores (1 socket x 2 cores/socket = 2 cores)
  2973. Core(s) per socket: 2
  2974. Socket(s): 1
  2975. * Of which each can run upto 1 threads
  2976. Thread(s) per core: 1
  2977. at the same time. These threads are the core's logical capabilities.
  2978. $ sudo dmidecode | egrep "Socket Designation: Proc|((Thread|Core) Count)"
  2979. Socket Designation: Proc 1
  2980. Core Count: 14
  2981. Thread Count: 28
  2982. Socket Designation: Proc 2
  2983. Core Count: 14
  2984. Thread Count: 28
  2985. * Two sockets.
  2986. * Each socket has 14 physical cores.
  2987. * Each core has two threads (28/14).
  2988. * Total number of logical "cpus" or logical processing units is 56.
  2989. (that's what top and some other commands would show you as number of "cpus")
  2990. # show applications using the internet
  2991. $ lsof -i | awk '{print $1}' | uniq | tail -n +2
  2992. * lsof -i shows us a lot of information pertaining to
  2993. processes accessing the Internet
  2994. * awk '{print $1}' filters the last output to only shown
  2995. us the COMMAND column
  2996. * uniq filters out multiple occurrences of a single application
  2997. * tail -n +2 removes the first COMMAND line
  2998. # concatenating pdf files in linux
  2999. To convert an image to a pdf we can use imagemagick:
  3000. $ convert -quality 100 image.pdf scanned.pdf
  3001. To combine or concatenate multiple pdf files, we can use ghostscript:
  3002. $ gs -sDEVICE=pdfwrite \
  3003. -sOUTPUTFILE=output.pdf \
  3004. -dNOPAUSE \
  3005. -dBATCH \
  3006. input0.pdf input1.pdf input2.pdf
  3007. Flag Description
  3008. -sDEVICE Device used for processing the output file type. Use
  3009. pdfwrite to write to a pdf file.
  3010. -sOUTPUTFILE Path to save the resulting file output.
  3011. -dNOPAUSE Disables the prompting and pausing at the end of each page.
  3012. -dBATCH Finishes interpreting after processing the inputted files.
  3013. Alternatively you can use pdftk:
  3014. $ pdftk input0.pdf input1.pdf input2.pdf \
  3015. cat output output.pdf
  3016. Lastly, you can also use imagemagick. Do note, however, that this program
  3017. often leads to larger file sizes.
  3018. $ convert input0.pdf input1.pdf input2.pdf output.pdf
  3019. One issue is that if the pages were of different sizes. This is often because
  3020. the pages can be of different pixel densities.
  3021. To check run pdfimages and look at the 3rd to last and 2nd to last columns:
  3022. $ pdfimages -list filename.pdf
  3023. We can then use imagemagick to enforce a certain pixel density. The tradeoff
  3024. being that the file size might increase.
  3025. $ convert -density 300 input.pdf output.pdf
  3026. # brief cheat sheat with curl
  3027. $ curl cheat.sh/<command>
  3028. # change and print terminal line settings
  3029. $ stty --all # print all current settings in human-readable form
  3030. $ stty --save # print all current settings in a stty-readable form
  3031. $ stty --file=DEVICE # open and use the specified DEVICE instead of stdin
  3032. $ stty --help # display this help and exit
  3033. $ stty --version # output version information and exit
  3034. # use plaintext gmail
  3035. 1. Compose a new message
  3036. 2. On the bottom right, click the three-dotted icon
  3037. 3. Select the plaintext option
  3038. Gmail will remember your preference next time.
  3039. Gmail wraps plain text messages at 78 characters.
  3040. # how to add swap space on debian 11
  3041. Swap is a portion of hard drive storage that has been set aside for the
  3042. operating system to temporarily store data that it can no longer hold in RAM.
  3043. checking the system for swap information:
  3044. $ sudo swapon --show # if the system has any configured swap
  3045. If you don't get back any output, this means your system does not have swap
  3046. space available currently.
  3047. $ free -h # verify that there is no active swap using the free utility
  3048. checking available space on the hard drive partition:
  3049. $ df -h # check current disk usage to make sure we have enough space
  3050. The device with / in the 'Mounted on' column is our disk in this case.
  3051. creating a swap file:
  3052. We will allocate a file of the size that we want called swapfile in our root
  3053. directory.
  3054. $ sudo fallocate -l 4G /swapfile # creating a swap file with the fallocate
  3055. $ ls -lh /swapfile # verify that the correct amount of space was reserved
  3056. enabling the swap file:
  3057. $ sudo chmod 600 /swapfile # make the file only accessible to root
  3058. $ ls -lh /swapfile # verify the permissions change
  3059. $ sudo mkswap /swapfile # mark the file as swap space
  3060. $ sudo swapon /swapfile # enable the swap file, allowing our system to use
  3061. $ sudo swapon --show # verify that the swap is available
  3062. $ free -h # check the output of the free utility again to corroborate
  3063. making the swap file permanent:
  3064. $ sudo cp /etc/fstab /etc/fstab.bk # back up the /etc/fstab file
  3065. Add the swap file information to the end of your /etc/fstab file
  3066. $ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
  3067. adjusting the swappiness property:
  3068. The swappiness parameter configures how often your system swaps data out of RAM
  3069. to the swap space. This is a value between 0 and 100 that represents a
  3070. percentage.
  3071. $ cat /proc/sys/vm/swappiness # the current swappiness value
  3072. $ sudo sysctl vm.swappiness=10 # using the sysctl command to set swappiness
  3073. This setting will persist until the next reboot. We can set this value
  3074. automatically at restart by adding the line to /etc/sysctl.conf file
  3075. $ sudo vi /etc/sysctl.conf
  3076. At the bottom, you can add
  3077. vm.swappiness=10
  3078. adjusting the cache pressure setting:
  3079. This setting configures how much the system will choose to cache inode and
  3080. dentry information over other data.
  3081. $ cat /proc/sys/vm/vfs_cache_pressure # current value by querying the proc
  3082. $ sudo sysctl vm.vfs_cache_pressure=50 # set the cache pressure setting value
  3083. This setting will persist until the next reboot. We can set this value
  3084. automatically at restart by adding the line to /etc/sysctl.conf file
  3085. $ sudo vi /etc/sysctl.conf
  3086. At the bottom, add the line that specifies the new value
  3087. vm.vfs_cache_pressure=50
  3088. Ref: digitalocean.com/community/tutorials/how-to-add-swap-space-on-debian-11
  3089. # find ip address of remote machine for ssh connection
  3090. 1. find ip address of local machine
  3091. $ ip addr [192.168.29.175/24]
  3092. 2. use nmap to find all ip address in the network
  3093. $ nmap -sn 192.168.29.0/24
  3094. $ nmap -sn 192.168.29.1-254/24 | egrep "scan report" | awk '{print $5}'
  3095. $ doas arp-scan --interface=eno1 --localnet # discover all hosts on the local network
  3096. # drivers used by sound card
  3097. $ lspci -knn | grep -iA2 audio
  3098. # swiss army knife
  3099. strace
  3100. ngrep
  3101. netstat
  3102. wireshark
  3103. eBPF
  3104. /proc
  3105. perf
  3106. ps
  3107. # strace - diagnostic, instructional, and debugging tool
  3108. $ strace ./revlist.py
  3109. $ strace -e file ./revlist.py # file calls
  3110. $ strace -e read ./revlist.py # read calls
  3111. $ strace -e write ./revlist.py # write calls
  3112. $ strace -e network ./revlist.py # network calls
  3113. $ strace -e network curl mark.mcnally.je # network socket information
  3114. $ strace -e connect curl mark.mcnally.je # connect information
  3115. $ strace -p <process id> -e connect # network calls <process id> making
  3116. $ strace -o file.txt ./revlist.py # save output in file.txt
  3117. $ strace -t ./revlist.py # include time stamp
  3118. $ strace -c ./revlist.py # summarize
  3119. $ strace -p <vim process id> -e read # strace vim read calls
  3120. # regex
  3121. $ grep text file.txt
  3122. $ grep text file.txt -o | wc -l
  3123. $ grep Text file.txt -o | wc -l
  3124. $ grep [tT]ext file.txt -o | wc -l
  3125. $ grep "^t" file.txt # ^ - matches t at start of the line
  3126. $ grep "t$" file.txt # $ - matches t at end of the line
  3127. $ grep "t." file.txt # . - matches t and one char after t
  3128. $ grep "t.*" file.txt # * - matches t and all other char after t
  3129. $ grep -E [t]{2} file.txt # repeat t twice (example: tt in twitter)
  3130. $ grep -E "^[a-z]*@.*$" file.txt # grep email address (E - extended)
  3131. # fzf - a general-purpose command-line fuzzy finder
  3132. # install
  3133. $ git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
  3134. $ ~/.fzf/install
  3135. # upgrading
  3136. $ cd ~/.fzf && git pull && ./install
  3137. # command-line
  3138. $ history | fzf
  3139. # find and replace string with sed
  3140. Ref: https://linuxize.com/post/how-to-use-sed-to-find-and-replace-string-in-files/
  3141. $ sed -i 's/search_regex/replacement/g' *.txt
  3142. where,
  3143. -i By default, sed writes its output to the standard output. This
  3144. option tells sed to edit files in place. If an extension is supplied
  3145. (ex: i.bak), a backup of the original file is created.
  3146. s The substitute command, probably the most used command in sed.
  3147. / / / Delimiter character. It can be any character but usually the slash (/)
  3148. character is used.
  3149. search_regex Normal string or a regular expression to search for.
  3150. replacement The replacement string.
  3151. g Global replacement flag. By default, sed reads the file line by line
  3152. and changes only the first occurrence of the search_regex on a line.
  3153. When the replacement flag is provided, all occurrences are replaced.
  3154. Note: It is a good practice to put quotes around the argument so the shell
  3155. meta-characters won't expand.
  3156. # command line tool for manipulating multi-page djvu document
  3157. Reference: https://manpages.debian.org/testing/djvulibre-bin/index.html
  3158. $ doas apt-get install djvulibre-bin
  3159. $ man djvused
  3160. $ djvused -e n file.djvu # print the number of pages of the file file.djvu
  3161. $ djvm -delete file.djvu 2 # remove page 2 from file.djvu and save as file.djvu
  3162. $ djvused -v file.djvu # interactive mode
  3163. djvused: type "help" to see available commands.
  3164. djvused: ok.
  3165. <Ctrl> C
  3166. # djvu -> ps -> pdf
  3167. $ djvups -mode=foreground -gray input.djvu output.ps
  3168. $ djvups -mode=black input.djvu output.ps
  3169. $ djvups -mode=color input.djvu output.ps # default -mode=color
  3170. $ ps2pdf output.ps
  3171. # djvu rendering library
  3172. $ doas apt-get install djvulibre-bin
  3173. * djvm - manipulate bundled multi-page DjVu documents
  3174. * djvudigital - creates DjVu files from PS or PDF files
  3175. * djvuextract - extract chunks from DjVu image files
  3176. * djvups - convert DjVu documents to PostScript
  3177. * djvutoxml - DjVuLibre XML tools
  3178. * djvuxmlparser - DjvuLibre XML tools
  3179. * djvmcvt - convert multi-page DjVu documents
  3180. * djvudump - display internal structure of DjVu files
  3181. * djvumake - assemble DjVu image files
  3182. * djvused - multi-purpose DjVu document editor
  3183. * djvutxt - extract the hidden text from DjVu documents
  3184. # compare directories
  3185. $ diff -qr /path/to/directory1 /path/to/directory2
  3186. $ diff -qrs /path/to/directory1 /path/to/directory2
  3187. options:
  3188. -q (--brief) report only when files differ
  3189. -r (--recursive) recursively compare any subdirectories found
  3190. -s (--report-identical-files) report when two files are the same
  3191. # pdf rendering library
  3192. $ doas apt-get install poppler-utils
  3193. * pdfdetach - lists or extracts embedded files (attachments)
  3194. * pdffonts - font analyzer
  3195. * pdfimages - image extractor
  3196. * pdfinfo - document information
  3197. * pdfseparate - page extraction tool
  3198. * pdfsig - verifies digital signatures
  3199. * pdftocairo - PDF to PNG/JPEG/PDF/PS/EPS/SVG converter using Cairo
  3200. * pdftohtml - PDF to HTML converter
  3201. * pdftoppm - PDF to PPM/PNG/JPEG image converter
  3202. * pdftops - PDF to PostScript (PS) converter
  3203. * pdftotext - text extraction
  3204. * pdfunite - document merging tool
  3205. # pdfjam
  3206. pdfjam is part of the TeX Live distribution.
  3207. $ doas apt-get install texlive-extra-utils
  3208. Among other features, it can be used to adjust PDF page sizes with an intuitive
  3209. syntax:
  3210. $ pdfjam --outfile output.pdf --paper a2paper input.pdf
  3211. $ pdfsize output.pdf
  3212. The --paper option must be followed by a valid LaTeX paper size. However, we can
  3213. use custom sizes with this syntax:
  3214. $ pdfjam --outfile output.pdf --papersize '{200mm,350mm}' input.pdf
  3215. $ pdfsize output.pdf
  3216. Unfortunately, hyperlinks and bookmarks are lost.
  3217. $ pdfjam infile1.pdf '{},2-' infile2.pdf '10,3-6' --outfile outfile.pdf
  3218. $ pdfjam infile.pdf --fitpaper true '4-' --outfile outfile.pdf
  3219. # pdfposter
  3220. pdfposter is to create posters by printing multiple pages of a PDF. However, we
  3221. can also use it to resize a PDF.
  3222. $ doas apt-get install pdfposter
  3223. Let's do a US letter to A2 conversion:
  3224. $ pdfposter -mA2 input.pdf output.pdf
  3225. $ pdfsize output.pdf
  3226. We can also specify custom sizes, 200x350mm:
  3227. $ pdfposter -m200x350mm input.pdf output.pdf
  3228. $ pdfsize output.pdf
  3229. # find minimum and maximum values
  3230. $ cut -f1 -d ' ' filename.txt | sort -n | head -1 # minimum
  3231. $ cut -f1 -d ' ' filename.txt | sort -n | tail -1 # maximum
  3232. # scan IP address connected to the network
  3233. nmap -sn 192.168.29.0/24 # disable port scanning, host discover only
  3234. ssh user@192.168.29.132