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.

265 lines
7.0 KiB

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