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.

351 lines
10 KiB

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