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.

271 lines
7.3 KiB

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