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.

365 lines
10 KiB

2 years ago
2 years 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. 3. [Getting some INFO about the system](#getting-some-info-about-the-system)
  20. 4. [Cool programs you find on almost all linux](#cool-programs-you-find-on-almost-all-linux)
  21. # Important Linux commands
  22. The commands which make life in cyberspace easier.
  23. In the shell, you have to imagine the jumps. Because the computer will only be
  24. projecting code in your mind from your mind.
  25. You are a specific point on some system, when you are in the shell.
  26. you can see what is in the directory you are with the command
  27. ## ls
  28. this command also can display other useful information. Of what is inside the directory
  29. you are in.
  30. ## cd
  31. The most important one.
  32. Instead to click, you change directories via command.
  33. that makes it possible to jump from one point to the other, especially with autocompletion.
  34. ## man
  35. In general you can get the manual entries for each of the programs described here and much more.
  36. Just type
  37. man cd
  38. or type
  39. man ls
  40. and you will get the manual opened historically with nano or less.. not sure, both good old editors.
  41. ## cp
  42. copy files from one place to another. (relatively from you)
  43. cp /dirA/file1.py /dirB/file1.py
  44. when there is already file1.py in the destination directory, it gets overwritten.
  45. ## Concept of piping with arrows
  46. in the shell you have standard input and standard output.
  47. Nothing more.
  48. to pipe the standard output from one program into a file, you write it like this:
  49. ls > file.txt
  50. When you write like that, youll overwrite everything in the file with the output.
  51. If you want to append to a file what a program has as standard output,
  52. you can use >> instead. Writing it like this:
  53. ls >> file.txt
  54. This both is piping. There is another very important aspect of piping described later.
  55. ## mkdir
  56. another basic command.
  57. Create a new directory ("make dir")
  58. ## su
  59. stands for super user.
  60. use it to become super user.
  61. 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.
  62. ## sudo
  63. this is a program you can put in front of commands, to get the superuser for only this command, typing your password of course.
  64. then for other x times writing sudo, you can issue commands as superuser without even typing in a password.
  65. ## alias
  66. give your complicated commands easy remember commands.
  67. Or build the own language of your shell.
  68. alias cls=clear
  69. 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.
  70. On my Arch Linux, I can write these aliases in my bashrc config file. I need to issue the command
  71. source bash_profile
  72. to get the configuration loaded. On other linux there will be an analogon.
  73. ## cat
  74. print out what you have in front of you on the standard output.
  75. also print several together
  76. for instance:
  77. cat doc1.txt doc2.txt > doc1ANDdoc2.txt
  78. ## chown
  79. On linux everything are only directories and (txt)files.
  80. All these objects have an owner, or also multiple ones.
  81. sudo chown -R root /ole/ola/kp.txt
  82. gives root the ownership of kp.txt
  83. ## chmod
  84. Every owner then has file permissions. That means he can read write or x (do) something.
  85. 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.
  86. sudo chmod 777 ole/oi/file.txt
  87. bzw
  88. sudo chmod 660 ole/oi/file.txt
  89. Just look it up what people say regarding permissions and certain directories.
  90. ## history
  91. this lists all the commands of the shell you are in, that you have typed in lastly.
  92. ## grep
  93. 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.
  94. GRAB it.
  95. grep -lr word
  96. 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.
  97. ## piping with the pipe
  98. here comes into account the piping with |.
  99. Directly combining it with the history command is pretty effective..
  100. history | grep "whatsoevercommandIalreadyfiguredoutbutreallydontwanttosearchoutagain"
  101. here the output of history gets piped into the program grep.
  102. as the output of history gives one command per line, grep will filter out exactly the command in which the pattern "whatsoever" occur.
  103. # the package manager(s)
  104. One of the biggest differences between different operating systems is their package
  105. 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.
  106. ## debian linux based apt
  107. APT stands for Advanced Packaging tool.
  108. If I want to install a package, first I look in the so called "mirrors" of my system.
  109. 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
  110. apt-cache search "library"
  111. then, to install the package, usually
  112. apt-get install "lib"
  113. is used.
  114. If you want to make some install breaking out of the system philosophy,
  115. sometimes you want to issue
  116. dpkg install "lib"
  117. The tool apt is build from dpkg.
  118. But if u use dpkg, you should know what youre doing.
  119. 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),
  120. then
  121. aptitude install "lib"
  122. is cool.
  123. It gives you different scenarios, listed in pretty complex manner, and you can choose
  124. 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.
  125. When you remove packages, with apt you have the possibility to either
  126. remove or purge the code.
  127. 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.
  128. ## Arch linux based pacman
  129. On Arch linux, pacman does a lot for you.
  130. To install, you use
  131. pacman -S "lib"
  132. To remove, you use
  133. pacman -R "lib"
  134. To search for packages, you use
  135. pacman -Ss "lib"
  136. 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
  137. pacaur -Ss "lib"
  138. or the other commands. Here most pacman commands work, the difference is you use pacaur without sudo.
  139. # getting some info about the system
  140. ## df
  141. prints you out disc usage of your hardware
  142. df -h
  143. does it in humanreadable
  144. ## du
  145. prints out the size of files around you
  146. du -h -d 2
  147. prints in human readable with depth 2, that means in the directories and in their subdirectories.
  148. ## lsblk
  149. prints you out all the hardware devices with memory
  150. ## lscpu
  151. prints you out info about the central processing unit
  152. ## lspci
  153. prints out lots of hardware, everything that is connected with pci, which means the fast stuff
  154. ## lsusb
  155. prints out everything connected with usb.
  156. 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.
  157. ## htop respectively top
  158. gives you a terminal graphics programm interface to see all running processes
  159. ## tail -f
  160. with tail or also head, you can print out the last or the first lines of a file
  161. When you use tail -f, you get a stream of the documents last lines.
  162. Thats perfect for some log files that get written.
  163. ## journalctl -f
  164. 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.
  165. The kernel is the ground software, running the hardware of the proper materia device.
  166. Its mostly in C.
  167. C is like the base of all languages. (if its not assembly)
  168. ## uname (-a or -r or other)
  169. gives you general infos about system, OS, and stuff
  170. ## systemctl
  171. some people do not like systemctl.
  172. I personally have parts of my structures that are managed by this software.
  173. with
  174. sudo systemctl status nginx.service
  175. 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.
  176. # cool programs you find on almost all linux
  177. ## ssh
  178. with ssh, the secure shell, you can be on other computers worldwide connected to the internet.
  179. 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
  180. ## scp
  181. thats copying from one computer to the other with the ssh protocol
  182. ## rsync
  183. 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.
  184. ## vnc
  185. is like ssh but for video
  186. ## torify
  187. the freedom of the internet is not a joke.
  188. with torify you can tunnel other programs over tor.
  189. 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.
  190. Just understanding a lot about tor is already helping a lot for our freedom.
  191. ## ncat
  192. on linux OSes, or probably also on other computers, a lot of things are organised in so called ports.
  193. ssh has port 22
  194. http has port 80
  195. https has port 443
  196. a lot of these ports have different programs that use them.
  197. 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.
  198. 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)).