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.

198 lines
4.8 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. # alias
  36. give your complicated commands easy remember commands.
  37. Or build the own language of your shell.
  38. alias cls=clear
  39. 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.
  40. On my Arch Linux, I can write these aliases in my bashrc config file. I need to issue the command
  41. source bash_profile
  42. to get the configuration loaded. On other linux there will be an analogon.
  43. # cat
  44. print out what you have in front of you on the standard output.
  45. also print several together
  46. for instance:
  47. cat doc1.txt doc2.txt > doc1ANDdoc2.txt
  48. # chown
  49. On linux everything are only directories and (txt)files.
  50. All these objects have an owner, or also multiple ones.
  51. sudo chown -R root /ole/ola/kp.txt
  52. gives root the ownership of kp.txt
  53. # chmod
  54. Every owner then has file permissions. That means he can read write or x (do) something.
  55. 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.
  56. sudo chmod 777 ole/oi/file.txt
  57. bzw
  58. sudo chmod 660 ole/oi/file.txt
  59. Just look it up what people say regarding permissions and certain directories.
  60. # history
  61. this lists all the commands of the shell you are in, that you have typed in lastly.
  62. # grep
  63. 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.
  64. GRAB it.
  65. # piping with |
  66. here comes into account the piping with |.
  67. Directly combining it with the history command is pretty effective..
  68. history | grep "whatsoevercommandIalreadyfiguredoutbutreallydontwanttosearchoutagain"
  69. here the output of history gets piped into the program grep.
  70. as the output of history gives one command per line, grep will filter out exactly the command in which the pattern "whatsoever" occur.
  71. # getting some INFO about the system
  72. # df
  73. prints you out disc usage of your hardware
  74. df -h
  75. does it in humanreadable
  76. # du
  77. prints out the size of files around you
  78. du -h -d 2
  79. prints in human readable with depth 2, that means in the directories and in their subdirectories.
  80. # lsblk
  81. prints you out all the hardware devices with memory
  82. # htop respectively top
  83. gives you a terminal graphics programm interface to see all running processes
  84. # tail -f
  85. with tail or also head, you can print out the last or the first lines of a file
  86. When you use tail -f, you get a stream of the documents last lines.
  87. Thats perfect for some log files that get written.
  88. # journalctl -f
  89. 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.
  90. The kernel is the ground software, running the hardware of the proper materia device.
  91. Its mostly in C.
  92. C is like the base of all languages. (if its not assembly)
  93. # uname (-a or -r or other)
  94. gives you general infos about system, OS, and stuff
  95. # systemctl
  96. some people do not like systemctl.
  97. I personally have parts of my structures that are managed by this software.
  98. with
  99. sudo systemctl status nginx.service
  100. 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.