R8934

Usefull linux commands

Aug 15th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. This list will get continues updates. So bookmark this page if you think it is usefull!
  2.  
  3. list all installed packages with a short description:
  4. - dpkg-query -l
  5.  
  6. Count all files in the folder named maps:
  7. - find maps -type f | wc -l
  8.  
  9.  
  10. Check free diskspace:
  11. - df -h
  12.  
  13. Delete a folder and the content inside
  14. - rm -rf foldername
  15.  
  16. //=================================== Cronjobs ================================================================//
  17.  
  18. See cronjobs:
  19. - crontab -l
  20. Or for a user:
  21. - crontab -l -u username
  22.  
  23. contains all the configured crontabs of all users - except the root user who is also able to configure jobs via the system-wide crontab, which is located at /etc/crontab
  24. With cronie (default on Fedora/CentOS), there is a .d style config directory for system cron jobs, as well:
  25.  
  26. - /etc/cron.d
  27. (As always, the .d directory simplifies maintaining configuration entries that are part of different packages.)
  28.  
  29. For convenience, most distributions also provide a directories where linked/stored scripts are periodically executed, e.g.:
  30.  
  31. /etc/cron.daily
  32. /etc/cron.hourly
  33. /etc/cron.monthly
  34. /etc/cron.weekly
  35.  
  36. //==================================== Nano notes ==============================================================//
  37.  
  38. Go to line 100 in a certain file:
  39. # nano +100 /var/www/html/test/test.php
  40.  
  41. Or when in nano you can use ctrl-_ (ctrl + shift and -) to enter a line number to go to.
  42.  
  43.  
  44. //===============================================================================================================//
  45. chown stands for: change file owner and group.
  46.  
  47. Free command shows free, total and swap memory information in bytes.
  48. # free
  49.  
  50. To recursively give directories read&execute privileges:
  51. # find /path/to/base/dir -type d -exec chmod 755 {} +
  52. To recursively give files read privileges:
  53. # find /path/to/base/dir -type f -exec chmod 644 {} +
  54.  
  55.  
  56.  
  57. //==================================== How to know wich linux version =========================================//
  58. # cat /proc/version
  59. Output will be:
  60. - Linux version 2.6.13-15-default (geeko@buildhost) (gcc version 4.0.2 20050901 (prerelease) (SUSE Linux)) #1 Tue Sep 13 14:56:
  61. UTC 2005
  62.  
  63. More specific:
  64. # cat /etc/issue
  65. Output will be:
  66. - Welcome to SUSE LINUX 10.0 (i586) - Kernel \r (\l).
  67.  
  68. //============================================================================================================//
  69. I tried "php -v"
  70. A command like this will only work if you have the CLI version of PHP installed. If you have only the Apache module version of PHP this will not work.
  71.  
  72. You can install the CLI version with this command:
  73.  
  74. apt-get install php5-cli
  75. //============================================================================================================//
  76. Command chaining:
  77. # sudo mkdir test; cd test; sudo mkdir yetAnotherTest; cd yetAnotherTest
  78.  
  79. //=========================
  80. Grant user rights to edit /var/www
  81. sudo chown -R username /dfvar/www
  82.  
  83.  
  84.  
  85. //======= Recover root password ===========//
  86. If you forgot your root password for your debian server use the following procedure to reset.
  87. Boot to the GRUB menu. Then, press <e> (for edit) before Linux has a chance to boot.
  88.  
  89. Using your keyboard arrow keys, move the cursor down a line or so, and press <e> (for edit) again, you should now be on the kernel line, and press <End> to go out to the very end of that line. Now hit the spacebar once, if necessary, to add a space, and then add one of the folllowing:
  90.  
  91. init=/bin/bash
  92.  
  93. or
  94.  
  95. init=/bin/sh
  96.  
  97. Then press <Enter>, and you're back at the kernel line, press <b> (for boot) and the computer will proceed to boot to a root prompt.
  98.  
  99. At this point, the root file system is still mounted read-only, so enter the following command:
  100.  
  101. mount -n -o remount,rw /
  102.  
  103. Then type:
  104.  
  105. passwd
  106.  
  107. Enter your new password. Retype if asked to confirm.
  108. Then restart the machine by typing:
  109.  
  110. reboot
  111.  
  112. Now you should be able to login with your new root password as required.
  113.  
  114.  
  115. // =================
  116. How to set phpMyAdmin default 1440 second timeout higher:
  117. locate php.ini el@apollo:/var/lib/phpmyadmin$ locate php. ini /etc/php5/apache2/php. ini.
  118. open the file as root to edit, find this line: session. gc_maxlifetime = 1440.
  119. Change it to this (500000 seconds is 5.7 days) session. gc_maxlifetime = 500000.
  120. Restart apache.
Add Comment
Please, Sign In to add comment