The commands which make life in cyberspace easier
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

390 lines
11 KiB

1 year ago
1 year ago
2 years ago
  1. # Table of Contents
  2. 1. [Important Linux commands](#important-linux-commands)
  3. * [ls](#ls)
  4. * [cd](#cd)
  5. * [man](#man)
  6. * [cp](#cp)
  7. * [Concept of piping with arrows](#concept-of-piping-with-arrows)
  8. * [mkdir](#mkdir)
  9. * [su](#su)
  10. * [sudo](#sudo)
  11. * [alias](#alias)
  12. * [cat](#cat)
  13. * [chown](#chown)
  14. * [chmod](#chmod)
  15. * [history](#history)
  16. * [grep](#grep)
  17. * [piping with the pipe](#piping-with-the-pipe)
  18. 2. [The package manager(s)](#the-package-managers)
  19. * [debian linux based apt](#debian-linux-based-apt)
  20. * [Arch linux based pacman](#arch-linux-based-pacman)
  21. 3. [Getting some INFO about the system](#getting-some-info-about-the-system)
  22. * [df](#df)
  23. * [du](#du)
  24. * [lsblk](#lsblk)
  25. * [lscpu](#lscpu)
  26. * [lspci](#lspci)
  27. * [lsusb](#lsusb)
  28. * [htop respectively top](#htop-respectively-top)
  29. * [tail -f](#tail--f)
  30. * [journalctl -f](#journalctl--f)
  31. * [uname](#uname)
  32. * [systemctl](#systemctl)
  33. 4. [Cool programs you find on almost all linux](#cool-programs-you-find-on-almost-all-linux)
  34. * [ssh](#ssh)
  35. * [scp](#scp)
  36. * [rsync](#rsync)
  37. * [vnc](#vnc)
  38. * [torify](#torify)
  39. * [ncat](#ncat)
  40. # Important Linux commands
  41. The commands which make life in cyberspace easier.
  42. In the shell, you have to imagine the jumps. Because the computer will only be
  43. projecting code in your mind from your mind.
  44. You are a specific point on some system, when you are in the shell.
  45. you can see what is in the directory you are with the command
  46. ## ls
  47. this command also can display other useful information. Of what is inside the directory
  48. you are in.
  49. ## cd
  50. The most important one.
  51. Instead to click, you change directories via command.
  52. that makes it possible to jump from one point to the other, especially with autocompletion.
  53. you can jump back where you have been, by issuing
  54. cd -
  55. ## man
  56. In general you can get the manual entries for each of the programs described here and much more.
  57. Just type
  58. man cd
  59. or type
  60. man ls
  61. and you will get the manual opened historically with nano or less.. not sure, both good old editors.
  62. ## cp
  63. copy files from one place to another. (relatively from you)
  64. cp /dirA/file1.py /dirB/file1.py
  65. when there is already file1.py in the destination directory, it gets overwritten.
  66. ## Concept of piping with arrows
  67. in the shell you have standard input and standard output.
  68. Nothing more.
  69. to pipe the standard output from one program into a file, you write it like this:
  70. ls > file.txt
  71. When you write like that, youll overwrite everything in the file with the output.
  72. If you want to append to a file what a program has as standard output,
  73. you can use >> instead. Writing it like this:
  74. ls >> file.txt
  75. This both is piping. There is another very important aspect of piping described later.
  76. ## mkdir
  77. another basic command.
  78. Create a new directory ("make dir")
  79. ## su
  80. stands for super user.
  81. use it to become super user.
  82. then the symbol in your shell changes from $ which means you are normal user to # which is the sysmbol of being superuser, or in other words: root.
  83. ## sudo
  84. this is a program you can put in front of commands, to get the superuser for only this command, typing your password of course.
  85. then for other x times writing sudo, you can issue commands as superuser without even typing in a password.
  86. ## alias
  87. give your complicated commands easy remember commands.
  88. Or build the own language of your shell.
  89. alias cls=clear
  90. This sets up an alias called cls. It will be another name for clear. When you type cls, it will clear the screen just as though you had typed clear.
  91. On my Arch Linux, I can write these aliases in my bashrc config file. I need to issue the command
  92. source bash_profile
  93. to get the configuration loaded. On other linux there will be an analogon.
  94. ## cat
  95. print out what you have in front of you on the standard output.
  96. also print several together
  97. for instance:
  98. cat doc1.txt doc2.txt > doc1ANDdoc2.txt
  99. ## chown
  100. On linux everything are only directories and (txt)files.
  101. All these objects have an owner, or also multiple ones.
  102. sudo chown -R root /ole/ola/kp.txt
  103. gives root the ownership of kp.txt
  104. ## chmod
  105. Every owner then has file permissions. That means he can read write or x (do) something.
  106. he can do all of them or some of them or none of them. Thats defined in codes, 777 gives them all and 660 doesnt completely.
  107. sudo chmod 777 ole/oi/file.txt
  108. bzw
  109. sudo chmod 660 ole/oi/file.txt
  110. Just look it up what people say regarding permissions and certain directories.
  111. ## history
  112. this lists all the commands of the shell you are in, that you have typed in lastly.
  113. The list consists of the command plus the a number. After have issued history (ususally filtered by grep with piping - see next chapter) you can directly issue one of the displayed commands WITHOUT using the mouse, by entering the an exclamation mark followed by the number of the command.
  114. ## grep
  115. if you have some bigger output of some of the former commands for example. Or whatever big output. then use grep to filter out the lines that have a certain word in it.
  116. GRAB it.
  117. grep -lr word
  118. is pretty cool. It searches you all the files recursively from your point in cyberspace - if they have in that "word". If yes, than the command will print out the file.
  119. ## piping with the pipe
  120. here comes into account the piping with |.
  121. Directly combining it with the history command is pretty effective..
  122. history | grep "whatsoevercommandIalreadyfiguredoutbutreallydontwanttosearchoutagain"
  123. here the output of history gets piped into the program grep.
  124. as the output of history gives one command per line, grep will filter out exactly the command in which the pattern "whatsoever" occur.
  125. # the package manager(s)
  126. One of the biggest differences between different operating systems is their package
  127. manager. Or better, the different programs for managing installations, removal etc of all software. For a software, to get into the collection of a certain OS, can be more or less difficult. In Arch Linux for instance, you will find some of the latest stuff. On other systems, like trisquel linux, you wont find closed source stuff. The package manager is the software which talks to these package collections.
  128. ## Debian linux based apt
  129. APT stands for Advanced Packaging tool.
  130. If I want to install a package, first I look in the so called "mirrors" of my system.
  131. What versions are available? What further tools, connected with the software I wanted to install, are also available? For debian, an option is to use
  132. apt-cache search "library"
  133. then, to install the package, usually
  134. apt-get install "lib"
  135. is used.
  136. If you want to make some install breaking out of the system philosophy,
  137. sometimes you want to issue
  138. dpkg install "lib"
  139. The tool apt is build from dpkg.
  140. But if u use dpkg, you should know what youre doing.
  141. If you get into conflicts, which means you have massively a lot of software and a new install breaks dependencies (this shouldn't happen, but it did to me),
  142. then
  143. aptitude install "lib"
  144. is cool.
  145. It gives you different scenarios, listed in pretty complex manner, and you can choose
  146. what way to go. Choosing what software should break, which not, or maybe there is even a solution enabling everything you want to run at the same time.
  147. When you remove packages, with apt you have the possibility to either
  148. remove or purge the code.
  149. The one is deleting everything, the other is deleting the software but leaving configurations etc. Such that in case youll get the software again, you can kind of start from the point you were. But sometimes Everythings broken because of broken configurations. Then deleting everything can make everything running again.
  150. ## Arch linux based pacman
  151. On Arch linux, pacman does a lot for you.
  152. To install, you use
  153. pacman -S "lib"
  154. To remove, you use
  155. pacman -R "lib"
  156. To search for packages, you use
  157. pacman -Ss "lib"
  158. To search in the user repository, and to install the stuff you can find there (stuff not quite on the same level as on the arch system repo, but sometimes prototypes and unstable but nice stuff) you can use
  159. pacaur -Ss "lib"
  160. or the other commands. Here most pacman commands work, the difference is you use pacaur without sudo.
  161. # getting some info about the system
  162. ## df
  163. prints you out disc usage of your hardware
  164. df -h
  165. does it in humanreadable
  166. ## du
  167. prints out the size of files around you
  168. du -h -d 2
  169. prints in human readable with depth 2, that means in the directories and in their subdirectories.
  170. ## lsblk
  171. prints you out all the hardware devices with memory
  172. ## lscpu
  173. prints you out info about the central processing unit
  174. ## lspci
  175. prints out lots of hardware, everything that is connected with pci, which means the fast stuff
  176. ## lsusb
  177. prints out everything connected with usb.
  178. More than everything, prints you also nice codes in the format 666:666 which is a wonderful help for finding drivers for usb connected devices.
  179. ## htop respectively top
  180. gives you a terminal graphics programm interface to see all running processes
  181. ## tail -f
  182. with tail or also head, you can print out the last or the first lines of a file
  183. When you use tail -f, you get a stream of the documents last lines.
  184. Thats perfect for some log files that get written.
  185. ## journalctl -f
  186. this gives you a stream of the kernel messages, which are pretty a lot about a lot of different topics of the programs on your machine.
  187. The kernel is the ground software, running the hardware of the proper materia device.
  188. Its mostly in C.
  189. C is like the base of all languages. (if its not assembly)
  190. ## uname
  191. uname (-a or -r or other) gives you general infos about system, OS, and stuff
  192. ## systemctl
  193. some people do not like systemctl.
  194. I personally have parts of my structures that are managed by this software.
  195. with
  196. sudo systemctl status nginx.service
  197. I ask systemctl to give me the status of the nginx daemon, running in the background of my (and actually all of my machines there is running one nginx daemon) machine.
  198. # cool programs you find on almost all linux
  199. ## ssh
  200. with ssh, the secure shell, you can be on other computers worldwide connected to the internet.
  201. its basically the same thing as getting the standard shell programm of the system running the ssh daemon. but almost all systems do that as a standard
  202. ## scp
  203. thats copying from one computer to the other with the ssh protocol
  204. ## rsync
  205. better than scp because it can easily recover when something bad happens during the up or download of something big. from its syntax ssh alike.
  206. ## vnc
  207. is like ssh but for video
  208. ## torify
  209. the freedom of the internet is not a joke.
  210. with torify you can tunnel other programs over tor.
  211. with tor, with systemctl status/start/stop tor.service, with reading and writing the torrc (THE configuration file of tor) you can easily host a knot point or a bridge.
  212. Just understanding a lot about tor is already helping a lot for our freedom.
  213. ## ncat
  214. on linux OSes, or probably also on other computers, a lot of things are organised in so called ports.
  215. ssh has port 22
  216. http has port 80
  217. https has port 443
  218. a lot of these ports have different programs that use them.
  219. already over knowing these ports and their programs, you get to know GROUND computer stuff. OLD computer stuff. pretty strong stuff all coders kinda agreed and agree on.
  220. with ncat, ports arent a problem anymore. just pip any port on any port (in the end, ports are also only directories, because there are only dirs and files on UNIX (kinda linux and apple together)).